public async Task GetFranchise_Found_Success() { // ARRANGE var rosettaStoneServiceMock = new Mock <IRosettaStoneService>(); var loggerMock = new Mock <ILogger <HomeController> >(); var unitUnderTest = new HomeController(rosettaStoneServiceMock.Object, loggerMock.Object); var franchiseNumber = "1"; var expected = new RosettaFranchise { clear_care_agency = 222, franchise_number = franchiseNumber }; rosettaStoneServiceMock.Setup(mock => mock.GetFranchise(franchiseNumber)) .ReturnsAsync(expected) .Verifiable(); // ACT var actionResult = await unitUnderTest.GetFranchise(franchiseNumber); // ASSERT rosettaStoneServiceMock.Verify(); var result = actionResult.Result as OkObjectResult; Assert.IsNotNull(result); var resultFranchise = result.Value as RosettaFranchise; Assert.IsNotNull(resultFranchise); Assert.AreEqual(expected.clear_care_agency, resultFranchise.clear_care_agency); }
public async Task GetFranchises_Success() { // ARRANGE var rosettaStoneServiceMock = new Mock <IRosettaStoneService>(); var loggerMock = new Mock <ILogger <HomeController> >(); var unitUnderTest = new HomeController(rosettaStoneServiceMock.Object, loggerMock.Object); var franchiseNumber = 1; var expected = new RosettaFranchise { clear_care_agency = 222, franchise_number = franchiseNumber.ToString() }; rosettaStoneServiceMock.Setup(mock => mock.GetFranchises()) .ReturnsAsync(new List <RosettaFranchise> { expected }) .Verifiable(); // ACT var actionResult = await unitUnderTest.GetFranchises(); // ASSERT rosettaStoneServiceMock.Verify(); var result = actionResult.Result as OkObjectResult; Assert.IsNotNull(result); var rosettaFranchises = result.Value as IList <RosettaFranchise>; Assert.IsNotNull(rosettaFranchises); Assert.AreEqual(expected.clear_care_agency, rosettaFranchises.First().clear_care_agency); }