コード例 #1
0
        static void Main(string[] args)
        {
            Bike     bike = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            BikeShop bs   = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            bs.UpdateBike(bike, "Ny description!", 5.0M);

            Bike updatedBike = new Bike(2, "TestBike", "TestFirma", "Gul", 5.0M, "Ny description!");

            if (bs.BikeDict.ContainsKey(bike))
            {
                Console.WriteLine("no");
            }
            else
            {
                Console.WriteLine("yes");
            }


            bs.OrderBikesFromStorage(bike, 10);

            Console.Read();
        }
コード例 #2
0
        public void CreateBikeTest()
        {
            Bike     bike = new Bike(2, "HurtigDrengen", "Lynet", "Gul", 19999.99M, "En meget hurtig cykel!");
            BikeShop bs   = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            Assert.That(bs.BikeDict.ContainsKey(bike));
        }
コード例 #3
0
        public void ReadBikeTest()
        {
            Bike     bike = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            BikeShop bs   = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            Assert.That(bs.BikeDict.ContainsKey(bike));
            Assert.NotNull(bs.LookAtBike(bike));
        }
コード例 #4
0
        public void SellBikeTest()
        {
            Bike     bike = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            BikeShop bs   = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            Assert.That(bs.BikeDict.ContainsKey(bike));

            bs.SellBike(bike);

            Assert.AreEqual(0, bs.BikeDict[bike]);
            Assert.AreEqual(bike.Price, bs.Earnings);

            int quantity = 100;

            bs.AddBike(bike, quantity);

            bs.SellBike(bike);
            Assert.AreEqual(quantity - 1, bs.BikeDict[bike]);
            Assert.AreEqual(bike.Price * 2, bs.Earnings);
        }
コード例 #5
0
        public void DeleteBikeTest()
        {
            Bike     bike = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            BikeShop bs   = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            Assert.That(bs.BikeDict.ContainsKey(bike));

            bs.RemoveBikeFromInventory(bike);

            Assert.False(bs.BikeDict.ContainsKey(bike));
        }
コード例 #6
0
        public void UpdateBikeTest()
        {
            Bike     bike         = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            Bike     originalBike = new Bike(2, "TestBike", "TestFirma", "Gul", 19999.99M, "En test cykel!");
            BikeShop bs           = new BikeShop("TestShop", "TestArea", 0000);

            bs.AddBike(bike);

            Assert.That(bs.BikeDict.ContainsKey(bike));
            bs.UpdateBike(bike, "Ny description!", 5.0M);

            Assert.That(bs.BikeDict.ContainsKey(bike));
            Assert.False(bs.BikeDict.ContainsKey(originalBike));
        }