Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor();
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);
        }
Ejemplo n.º 2
0
        public void Process_OrderIsNotShipped_ShouldSetTheShipmentPropertyOfTheOrder()
        {
            var orderProcessor = new OrderProcessor(new FakeShippingCalculator());
            var order = new Order();

            orderProcessor.Process(order);

            Assert.IsTrue(order.IsShipped);
            Assert.AreEqual(1, order.Shipment.Cost);
            Assert.AreEqual(DateTime.Today.AddDays(1), order.Shipment.ShippingDate);
        }
Ejemplo n.º 3
0
        public void Process_OrderIsAlreadyShipped_ThrowsAnException()
        {
            var orderProcessor = new OrderProcessor(new FakeShippingCalculator());

            var order = new Order
            {
                Shipment = new Shipment()
            };

            orderProcessor.Process(order);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var shippingCalculator = new ShippingCalculator();
            var orderProcessor     = new OrderProcessor(shippingCalculator);

            var order = new Order()
            {
                TotalPrice = 100f
            };

            orderProcessor.Process(order);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            //InterfaceViaPolymorphism

            var videoEncoder = new VideoEncoder();

            videoEncoder.RegisterNotificationChannel(new MailNotificationChannel());
            videoEncoder.RegisterNotificationChannel(new SmsNotificationChannel());
            videoEncoder.Encode();


            //OCP
            //var dbMigrator = new DbMigrator(new ConsoleLogger());
            var dbMigrator = new DbMigrator(new FileLogger(@"C:\Study\file.txt"));

            dbMigrator.Migrate();

            //OrderProcessor
            var order = new Order
            {
                TotalPrice = 20f,
                DatePlaced = DateTime.Now
            };
            var orderProcssor = new OrderProcessor(new ShippingCalculator());

            orderProcssor.Process(order);
            var user = new User
            {
                Status = RegistrationStatus.Active,
                Type   = UserType.Admin
            };

            if (user.Type == UserType.Admin && user.Status == RegistrationStatus.Active)
            {
                Console.WriteLine("Login Successfull...");
            }
        }