public IResult <ILotStatInfoReturn> SetLotHoldStatus(ISetLotHoldStatusParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var parsedParameters = parameters.ToParsedParameters(); if (!parsedParameters.Success) { return(parsedParameters.ConvertTo <ILotStatInfoReturn>()); } var result = new SetLotHoldCommand(_lotUnitOfWork).Execute(parsedParameters.ResultingObject, _timeStamper.CurrentTimeStamp); if (!result.Success) { return(result.ConvertTo <ILotStatInfoReturn>()); } _lotUnitOfWork.Commit(); var synchronizeLotParameters = new SynchronizeLotParameters { LotKey = parsedParameters.ResultingObject.LotKey, OverrideOldContextLotAsCompleted = false }; return(SyncParameters.Using(new SuccessResult <ILotStatInfoReturn>(new LotStatInfoReturn(synchronizeLotParameters)), synchronizeLotParameters)); }
public IResult <ILotStatInfoReturn> SetLotHoldStatus(ISetLotHoldStatusParameters parameters) { try { return(_lotServiceProvider.SetLotHoldStatus(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <ILotStatInfoReturn>(null, ex.Message)); } }
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); }
internal static IResult <SetLotHoldStatusParameters> ToParsedParameters(this ISetLotHoldStatusParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey); if (!lotKeyResult.Success) { return(lotKeyResult.ConvertTo <SetLotHoldStatusParameters>(null)); } return(new SuccessResult <SetLotHoldStatusParameters>(new SetLotHoldStatusParameters { Parameters = parameters, LotKey = new LotKey(lotKeyResult.ResultingObject) })); }