internal static void AssertAsExpected(this ICreateChileMaterialsReceivedItemParameters parameters, ChileMaterialsReceivedItem item) { Assert.AreEqual(parameters.GrowerCode, item.GrowerCode); Assert.AreEqual(parameters.ToteKey, item.ToteKey); Assert.AreEqual(parameters.Quantity, item.Quantity); Assert.AreEqual(parameters.Variety, item.ChileVariety); Assert.AreEqual(parameters.PackagingProductKey, new PackagingProductKey(item).KeyValue); Assert.AreEqual(parameters.LocationKey, new LocationKey(item).KeyValue); }
internal static IResult <SetChileMaterialsReceivedItemParameters> ToParsedParameters(this ICreateChileMaterialsReceivedItemParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.Quantity <= 0) { return(new InvalidResult <SetChileMaterialsReceivedItemParameters>(null, UserMessages.QuantityNotGreaterThanZero)); } var toteKeyResult = ToteKeyParser.Parse(parameters.ToteKey); if (!toteKeyResult.Success) { return(toteKeyResult.ConvertTo <SetChileMaterialsReceivedItemParameters>()); } var packagingProductKeyResult = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.PackagingProductKey); if (!packagingProductKeyResult.Success) { return(packagingProductKeyResult.ConvertTo <SetChileMaterialsReceivedItemParameters>()); } var locationKeyResult = KeyParserHelper.ParseResult <ILocationKey>(parameters.LocationKey); if (!locationKeyResult.Success) { return(locationKeyResult.ConvertTo <SetChileMaterialsReceivedItemParameters>()); } return(new SuccessResult <SetChileMaterialsReceivedItemParameters>(new SetChileMaterialsReceivedItemParameters { GrowerCode = parameters.GrowerCode, ToteKey = toteKeyResult.ResultingObject, ChileVariety = parameters.Variety, Quantity = parameters.Quantity, PackagingProductKey = packagingProductKeyResult.ResultingObject.ToPackagingProductKey(), LocationKey = locationKeyResult.ResultingObject.ToLocationKey() })); }