public HttpResponseMessage SetStatus(string lotKey, SetLotStatusDto values) { var input = new SetLotStatusParameter { LotKey = lotKey, QualityStatus = values.Status, }; var result = _lotService.SetLotQualityStatus(_userIdentityProvider.SetUserIdentity(input)); return(result.ToMapped().Response <LotStatInfoResponse>(HttpVerbs.Put)); }
public void Returns200OnSuccess() { // arrange MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>())) .Returns(new SuccessResult <ILotStatInfoReturn>()); const string lotKey = "12345"; const LotQualityStatus expectedStatus = LotQualityStatus.Released; var dto = new SetLotStatusDto { Status = expectedStatus }; // act var response = LotsControler.SetStatus(lotKey, dto); // assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
public void ParametersAreCorrectlyTransposedToDto() { // arrange ISetLotStatusParameters actualParameters = null; MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>())) .Callback((ISetLotStatusParameters p) => actualParameters = p) .Returns(new SuccessResult <ILotStatInfoReturn>()); const string lotKey = "12345"; const LotQualityStatus expectedStatus = LotQualityStatus.Released; var dto = new SetLotStatusDto { Status = expectedStatus }; // act LotsControler.SetStatus(lotKey, dto); // assert Assert.IsNotNull(actualParameters); Assert.AreEqual(lotKey, actualParameters.LotKey); Assert.AreEqual(expectedStatus, actualParameters.QualityStatus); }
public void UtilizesUserIdentityProvider() { // arrange const string lotKey = "12345"; const LotQualityStatus expectedStatus = LotQualityStatus.Released; var dto = new SetLotStatusDto { Status = expectedStatus }; SetLotStatusParameter actualParameters = null; MockUserIdentityProvider.Setup(m => m.SetUserIdentity(It.IsAny <SetLotStatusParameter>())) .Callback((SetLotStatusParameter p) => actualParameters = p) .Returns(actualParameters); MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>())) .Returns(new SuccessResult <ILotStatInfoReturn>()); // act LotsControler.SetStatus(lotKey, dto); // assert Assert.IsNotNull(actualParameters); MockUserIdentityProvider.Verify(m => m.SetUserIdentity(actualParameters), Times.Once()); }