internal static void AssertEqual(this ISampleOrderItemParameters expected, SampleOrderItem result) { if (!string.IsNullOrWhiteSpace(expected.SampleOrderItemKey)) { Assert.AreEqual(expected.SampleOrderItemKey, result.ToSampleOrderItemKey().KeyValue); } Assert.AreEqual(expected.Quantity, result.Quantity); Assert.AreEqual(expected.Description, result.Description); Assert.AreEqual(expected.CustomerProductName, result.CustomerProductName); if (!string.IsNullOrWhiteSpace(expected.ProductKey)) { Assert.AreEqual(expected.ProductKey, result.Product.ToProductKey().KeyValue); } else { Assert.IsNull(result.Product); if (!string.IsNullOrWhiteSpace(expected.LotKey)) { Assert.AreEqual(expected.LotKey, result.Lot.ToLotKey().KeyValue); } else { Assert.IsNull(result.Lot); } } }
internal static IResult <SetSampleOrderItemParameters> ToParsedParameters(this ISampleOrderItemParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } SampleOrderItemKey itemKey = null; if (!string.IsNullOrWhiteSpace(parameters.SampleOrderItemKey)) { var itemKeyResult = KeyParserHelper.ParseResult <ISampleOrderItemKey>(parameters.SampleOrderItemKey); if (!itemKeyResult.Success) { return(itemKeyResult.ConvertTo <SetSampleOrderItemParameters>()); } itemKey = itemKeyResult.ResultingObject.ToSampleOrderItemKey(); } ProductKey productKey = null; if (!string.IsNullOrWhiteSpace(parameters.ProductKey)) { var chileProductKeyResult = KeyParserHelper.ParseResult <IProductKey>(parameters.ProductKey); if (!chileProductKeyResult.Success) { return(chileProductKeyResult.ConvertTo <SetSampleOrderItemParameters>()); } productKey = chileProductKeyResult.ResultingObject.ToProductKey(); } LotKey lotKey = null; if (!string.IsNullOrWhiteSpace(parameters.LotKey)) { var chileLotKeyResult = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey); if (!chileLotKeyResult.Success) { return(chileLotKeyResult.ConvertTo <SetSampleOrderItemParameters>()); } lotKey = chileLotKeyResult.ResultingObject.ToLotKey(); } return(new SuccessResult <SetSampleOrderItemParameters>(new SetSampleOrderItemParameters { Parameters = parameters, SampleOrderItemKey = itemKey, ProductKey = productKey, LotKey = lotKey })); }