public void Parse() { var actual = VesselStatus.Parse(" p : .1 / -5 - -3 = -2.0 "); Assert.AreEqual(HInclinationStatus.P, actual.HStatus); Assert.AreEqual(0.1m, actual.HValue); Assert.AreEqual(-5m, actual.AftDraft); Assert.AreEqual(-3m, actual.ForeDraft); Assert.AreEqual(-2m, actual.VValue); }
private List <Receipt> GetTestReceipts() { var list = new List <Receipt> { new Receipt { No = "receipt 01", VesselName = "vessel 01", Time = DateTime.Now, ReceiptFor = "Load", PortOfShipment = "port of shipment 01", PortOfDestination = "port of destination 01", KindOfGoods = null, VesselStatus = VesselStatus.Parse("p:1/5-3=2"), TotalOfVolumeOfStandard = 0.1m, TotalOfVolume = 0.2m, TotalOfVolumeOfWater = 0.3m, TotalOfMass = 0.4m, TotalOfVolumeOfPipes = 0.5m, OperaterName = "OperaterName 01", AgentName = "AgentName 01", ShipperName = "ShipperName 01", ConsignerName = "ConsignerName 01", ConsigneeName = "ConsigneeName 01", ReceiptType = ReceiptType.DeliveryReceiptDestination }, new Receipt { No = "receipt 02", VesselName = "vessel 02", Time = DateTime.Now, ReceiptFor = "Load", PortOfShipment = "port of shipment 02", PortOfDestination = "port of destination 02", KindOfGoods = null, VesselStatus = VesselStatus.Parse("S:-.1/-1--0.8=-.2"), TotalOfVolumeOfStandard = 10.1m, TotalOfVolume = 10.2m, TotalOfVolumeOfWater = 10.3m, TotalOfMass = 10.4m, TotalOfVolumeOfPipes = 10.5m, OperaterName = "OperaterName 02", AgentName = "AgentName 02", ShipperName = "ShipperName 02", ConsignerName = "ConsignerName 02", ConsigneeName = "ConsigneeName 02", ReceiptType = ReceiptType.MassOfOil } }; list[0].ReceiptTankDetails.AddRange(this.GetTestReceiptTankDetails()); list[1].ReceiptTankDetails.AddRange(this.GetTestReceiptTankDetails()); return(list); }
private Receipt ReadReceipt(OleDbDataReader reader) { var readKindOfGoods = new Func <KindOfGoods>(() => { var uid = reader["KindOfGoodsUId"].ToStringOrNull(); if (uid == null) { return(null); } var kind = new KindOfGoods { UId = uid, Name = reader["KindOfGoodsName"].ToStringOrNull(), Customized = true }; if (String.IsNullOrEmpty(kind.Name)) { var builtInKind = Const.BuiltInKindsOfGoods.FirstOrDefaultRecursively(k => k.UId.Equals(kind.UId)); if (builtInKind != null) { kind = builtInKind; } } return(kind); }); return(new Receipt { No = reader["No"].ToStringOrNull(), VesselName = reader["VesselName"].ToStringOrNull(), Time = reader["Time"].TryToNullableDateTime(), ReceiptFor = reader["ReceiptFor"].ToStringOrNull(), PortOfShipment = reader["PortOfShipment"].ToStringOrNull(), PortOfDestination = reader["PortOfDestination"].ToStringOrNull(), KindOfGoods = readKindOfGoods(), VesselStatus = VesselStatus.Parse(reader["VesselStatus"].ToStringOrNull()), TotalOfVolumeOfStandard = reader["TotalOfVolumeOfStandard"].TryToNullableDecimal(), TotalOfVolume = reader["TotalOfVolume"].TryToNullableDecimal(), TotalOfVolumeOfWater = reader["TotalOfVolumeOfWater"].TryToNullableDecimal(), TotalOfMass = reader["TotalOfMass"].TryToNullableDecimal(), TotalOfVolumeOfPipes = reader["TotalOfVolumeOfPipes"].TryToNullableDecimal(), OperaterName = reader["OperaterName"].ToStringOrNull(), AgentName = reader["AgentName"].ToStringOrNull(), ShipperName = reader["ShipperName"].ToStringOrNull(), ConsignerName = reader["ConsignerName"].ToStringOrNull(), ConsigneeName = reader["ConsigneeName"].ToStringOrNull(), TimeSaved = reader["TimeSaved"].TryToDateTime(), ReceiptType = reader["ReceiptType"].ToReceiptType() }); }
public void VerifyThatShouldThrowWhileEquationIsWrong() { Exception actual = null; try { VesselStatus.Parse("p : .1 / 4 - 2 = 3"); } catch (Exception ex) { actual = ex; } Assert.AreEqual(typeof(FormatException), actual.GetType()); Assert.AreEqual(@"illegal equation, argument: s = p : .1 / 4 - 2 = 3", actual.Message); }
public void VerifyThatShouldThrowWhileFormatInvalid() { Exception actual = null; try { VesselStatus.Parse("k : .1 / 4 - 2 = 2"); } catch (Exception ex) { actual = ex; } Assert.AreEqual(typeof(FormatException), actual.GetType()); Assert.AreEqual(@"invalid status string to parse, argument: s = k : .1 / 4 - 2 = 2", actual.Message); }