public void CallsServiceMethodAsExpected() { // Arrange // Act LotsControler.Put(LotKey, _values); // Assert MockLotService.Verify(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()), Times.Once()); }
public void CallsServiceMethod() { // Arrange // Act LotsControler.Get(Key); // Assert MockLotService.Verify(m => m.GetLotSummary(Key), Times.Once()); }
public void Returns400AndBypassesServiceCallWhenModelIsInvalid() { // arrange var parameters = Fixture.Create <LotHoldDto>(); SystemUnderTest.ModelState.AddModelError("", "error message"); // act var result = SystemUnderTest.Put("02 14 01 001", parameters); // assert Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); Assert.IsNotNull(result.ReasonPhrase); MockLotService.Verify(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()), Times.Never()); }
public void CallsSetLotHoldStatusServiceMethodAsExpected() { // arrange const string expectedLotKey = "04 14 001 01"; var holdParameters = Fixture.Create <LotHoldDto>(); ISetLotHoldStatusParameters actualParameters = null; MockLotService.Setup(m => m.SetLotHoldStatus(It.IsAny <ISetLotHoldStatusParameters>())) .Callback((ISetLotHoldStatusParameters p) => { actualParameters = p; }) .Returns(new SuccessResult <ILotStatInfoReturn>()); // act SystemUnderTest.Put(expectedLotKey, holdParameters); // assert MockLotService.Verify(m => m.SetLotHoldStatus(It.IsAny <ISetLotHoldStatusParameters>()), Times.Once()); Assert.AreEqual(expectedLotKey, actualParameters.LotKey); Assert.AreEqual(holdParameters, actualParameters.Hold); }
public void ReturnsServiceResultOnSuccess() { // Arrange const int recordCount = 10; var expectedReturn = Fixture.Build <TestableLotSummariesReturn>() .With(m => m.LotSummaries, Fixture.CreateMany <ILotQualitySummaryReturn>(recordCount).AsQueryable()) .Create(); MockLotService.Setup(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>())) .Returns(() => new SuccessResult <ILotQualitySummariesReturn>(expectedReturn)); Assess.IsNotNull(expectedReturn); Assess.IsNotNull(expectedReturn.LotSummaries); // Act var result = LotsControler.Get(LotTypeEnum.Additive, pageSize: 10); // Assert MockLotService.Verify(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()), Times.Once()); Assert.AreEqual(recordCount, result.LotSummaries.Count()); }