Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Unit test. I would like to ask for a little help in this yet So my unit test is this presently public class HomeControllerTest {

Unit test. I would like to ask for a little help in this yet

So my unit test is this presently

public class HomeControllerTest { private Mock _staffRepository; private HomeController _controller; public HomeControllerTest() { _staffRepository = new Mock(); } [TestMethod] public async Task Get_StaffDetails_ReturnsOk() { // Arrange var id = 1; var staff = new Staff(); _staffRepository.Setup(repo => repo.Get(id)).Returns(staff); _controller = new HomeController(_staffRepository.Object); // Act var result = await _controller.GetAllStaff(int id); // Assert var objResult = result as ObjectResult; Assert.IsNotNull(objResult); // Ensure it's an ObjectResult Assert.AreEqual(staff, objResult.Value); // Check if the returned staff matches } } }

But I still have a little problem with it. The public HomeControllerTest()But

the HomeControllerTest is underlined with green and the (int id) is underlined with red here:

Thanks for the help in advance too.

var result = await _controller.GetAllStaff(int id);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions