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 AddTanks() { var tanks = new[] { new Tank { Name = "tank 01", Height = 11.1m }, new Tank { Name = "tank 02", Height = 22.2m } }; var tankDb = new TankDb(); tankDb.ClearTanks(); tankDb.Add(tanks); var actual = tankDb.GetAllTanks(); Assert.IsTrue(actual.Any(t => t.Name == "tank 01")); Assert.IsTrue(actual.Any(t => t.Name == "tank 02")); actual = new TankDb().GetAllTanks(); Assert.IsTrue(actual.Any(t => t.Name == "tank 01")); Assert.IsTrue(actual.Any(t => t.Name == "tank 02")); Assert.AreEqual(11.1m, actual.First(t => t.Name == "tank 01").Height); Assert.AreEqual(22.2m, actual.First(t => t.Name == "tank 02").Height); // add more tanks = new[] { new Tank { Name = "tank 03", Height = 33.3m } }; tankDb.Add(tanks); actual = tankDb.GetAllTanks(); Assert.AreEqual(3, actual.Count()); Assert.IsTrue(actual.Any(t => t.Name == "tank 01")); Assert.IsTrue(actual.Any(t => t.Name == "tank 02")); Assert.IsTrue(actual.Any(t => t.Name == "tank 03")); Assert.AreEqual(33.3m, actual.First(t => t.Name == "tank 03").Height); actual = new TankDb().GetAllTanks(); Assert.AreEqual(3, actual.Count()); Assert.IsTrue(actual.Any(t => t.Name == "tank 01")); Assert.IsTrue(actual.Any(t => t.Name == "tank 02")); Assert.IsTrue(actual.Any(t => t.Name == "tank 03")); Assert.AreEqual(33.3m, actual.First(t => t.Name == "tank 03").Height); }