Beispiel #1
0
        public void ClearTanks()
        {
            var tankDb = new TankDb();

            tankDb.ClearTanks();

            var actual = tankDb.GetAllTanks();

            Assert.AreEqual(0, actual.Count());
            actual = new TankDb().GetAllTanks();
            Assert.AreEqual(0, actual.Count());
        }
Beispiel #2
0
        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);
        }