public void AddOilVolumeItems() { var items = new[] { new OilVolume { TankName = "tank 01", HInclination = 0.1m, VInclination = 0.2m, Height = 0.3m, Volume = 0.4m }, new OilVolume { TankName = "tank 02", HInclination = 5m, VInclination = 0.6m, Height = 0.7m, Volume = 0.8m } }; var tankDb = new TankDb(); tankDb.ClearOilVolumeItems(); tankDb.Add(items); var actual = tankDb.GetAllOilVolumeItems(); Assert.AreEqual(2, actual.Count()); var item = actual.First(t => t.TankName.Equals("tank 01")); Assert.AreEqual(0.4m, item.Volume); Assert.AreEqual(0.3m, item.Height); Assert.AreEqual(0.2m, item.VInclination); Assert.AreEqual(0.1m, item.HInclination); item = actual.First(t => t.TankName.Equals("tank 02")); Assert.AreEqual(0.8m, item.Volume); Assert.AreEqual(0.7m, item.Height); Assert.AreEqual(0.6m, item.VInclination); Assert.AreEqual(5m, item.HInclination); // add more items = new[] { new OilVolume { TankName = "tank 03", HInclination = 0.09m, VInclination = 10m, Height = 1.1m, Volume = 1200m } }; tankDb.Add(items); actual = tankDb.GetAllOilVolumeItems(); Assert.AreEqual(3, actual.Count()); item = actual.First(t => t.TankName.Equals("tank 03")); Assert.AreEqual(1200m, item.Volume); Assert.AreEqual(1.1m, item.Height); Assert.AreEqual(10m, item.VInclination); Assert.AreEqual(0.09m, item.HInclination); actual = new TankDb().GetAllOilVolumeItems(); Assert.AreEqual(3, actual.Count()); item = actual.First(t => t.TankName.Equals("tank 03")); Assert.AreEqual(1200m, item.Volume); Assert.AreEqual(1.1m, item.Height); Assert.AreEqual(10m, item.VInclination); Assert.AreEqual(0.09m, item.HInclination); }
public void Import() { var importer = new TankCapacityImporter { AccessFile = ".\\Data\\Data.mdb" }; importer.RawDataFiles.AddRange(new[] { ".\\Data\\tank 01 raw data.txt", ".\\Data\\tank 02 raw data.txt" }); importer.Import(); var tankDb = new TankDb(); var vessel = tankDb.GetVessel(); var tanks = tankDb.GetAllTanks(); var volItems = tankDb.GetAllOilVolumeItems(); Assert.AreEqual("imported vessel 01", vessel.Name); Assert.AreEqual("imported cert 01", vessel.CertNo); Assert.IsTrue(tanks.Any(t => t.Name == "imported tank 01")); Assert.IsTrue(tanks.Any(t => t.Name == "imported tank 02")); Assert.AreEqual(27 + 8, volItems.Count()); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 01" && v.HInclination == -0.5m && v.VInclination == -0.6m && v.Height == 3m && v.Volume == 100m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 01" && v.HInclination == -0.5m && v.VInclination == 0m && v.Height == 1m && v.Volume == 99m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 01" && v.HInclination == 0m && v.VInclination == -0.3m && v.Height == 2m && v.Volume == 1099.2m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 01" && v.HInclination == 0.5m && v.VInclination == 0m && v.Height == 2m && v.Volume == 2099.3m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 02" && v.HInclination == -5m && v.VInclination == -6m && v.Height == 2m && v.Volume == 1m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 02" && v.HInclination == 0m && v.VInclination == -3m && v.Height == 1m && v.Volume == 8m)); Assert.IsTrue(volItems.Any(v => v.TankName == "imported tank 02" && v.HInclination == 0m && v.VInclination == -3m && v.Height == 2m && v.Volume == 6m)); Assert.IsTrue(!volItems.Any(v => v.TankName == "imported tank 02" && v.HInclination == 0m && v.VInclination == -3m && v.Height == 2m && v.Volume == 8m)); }
public void ClearOilVolumeItems() { var tankDb = new TankDb(); tankDb.ClearOilVolumeItems(); var actual = tankDb.GetAllOilVolumeItems(); Assert.AreEqual(0, actual.Count()); actual = new TankDb().GetAllOilVolumeItems(); Assert.AreEqual(0, actual.Count()); }