Пример #1
0
        public void _05_Creer_une_classe_abstraite_ItemDecorator_implementant_l_interface_item_et_initialisable_avec_un_item_et_faire_heriter_SpecialOffer_de_ItemDecorator()
        {
            Item offer   = new SpecialOffer(new Book("Dune", 10M), 10);
            Item soldout = new SoldOut(new SpecialOffer(new Book("Dune", 10M), 10));

            Assert.IsAssignableFrom <Item>(offer);
            Assert.IsAssignableFrom <ItemDecorator>(offer);
        }
Пример #2
0
        public void _04_Creer_une_classe_SpecialOffer_initialisable_avec_un_item_et_un_pourcentage_de_reduction()
        {
            Item book = new Book("Dune", 10M);

            SpecialOffer offer1 = new SpecialOffer(book, 10);

            Assert.Equal("Dune", offer1.Name);
            Assert.Equal(9M, offer1.Price);

            Item coffee = new Coffee("Expresso", 1M);

            SpecialOffer offer2 = new SpecialOffer(coffee, 5);

            Assert.Equal("Expresso", offer2.Name);
            Assert.Equal(0.95M, offer2.Price);
        }