static void Main(string[] args)
        {
            // publishers
            var rentalStore      = new RentalStore();
            var bolckbasterStore = new BlockbasterStore();


            // subscribers
            var mailService       = new EmailService();
            var pushNorifications = new PushNotifications();

            bolckbasterStore.Notifications += mailService.SendMail;
            bolckbasterStore.Notifications += pushNorifications.SendPushNotification;
            rentalStore.NotifyUsers        += mailService.SendMail;
            rentalStore.NotifyUsers        += pushNorifications.SendPushNotification;

            rentalStore.NotifyUsersVideoEvent += mailService.SendMail;
            rentalStore.NotifyUsersVideoEvent += pushNorifications.SendPushNotification;

            //bolckbasterStore.Notifications -= pushNorifications.SendPushNotification;

            rentalStore.AddNewMovie("Some movie");
            bolckbasterStore.NewMovieRelease("Treto poluvreme");

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void Invalid_items_should_not_be_included_in_total_price()
        {
            var request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);

            request.AddAccessory(new Refrigerator());

            var pricingFactory = PricingFactory.Create();
            var rental         = new RentalStore(pricingFactory).Rent(request);

            Assert.AreEqual(500M, rental.TotalPrice);
        }
Exemplo n.º 3
0
        public void Rental_prices_should_account_for_days_and_kilometers()
        {
            IVehicle carType = new PopularFamilyCar();
            var      request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);
            var      factory = PricingFactory.Create();

            var rental = new RentalStore(factory).Rent(request);

            Assert.AreEqual(4, rental.Days);
            Assert.AreEqual(200M, rental.TotalDailyPrice);
            Assert.AreEqual(300M, rental.EstimatedTotalKmPrice);
            Assert.AreEqual(500M, rental.TotalPrice);
        }
Exemplo n.º 4
0
        public void Rental_prices_should_account_for_valid_additional_items()
        {
            var request = BuildRentalRequest(new PopularFamilyCar(), 4, 600);

            request.AddAccessory(new CarSeat());

            var pricingFactory = PricingFactory.Create();
            var rental         = new RentalStore(pricingFactory).Rent(request);

            Assert.AreEqual(4, rental.Days);
            Assert.AreEqual(200M, rental.TotalDailyPrice);
            Assert.AreEqual(300M, rental.EstimatedTotalKmPrice);
            Assert.AreEqual(65M, rental.AdditionalItemsPrice);
            Assert.AreEqual(565M, rental.TotalPrice);
        }