예제 #1
0
 // used when we already have an order with an Id.
 public Order(IOrderDAO dao, IClient client, bool isDelivered = false)
 {
     this.flowers     = new List <Flower>();
     this.isDelivered = isDelivered;
     Client           = client;
     Id = dao.AddOrder(client);
 }
예제 #2
0
        public void Deliver(IOrderDAO dao)
        {
            IOrderDAO nu;

            this.isDelivered = true;
            dao.SetDelivered(this);
        }
예제 #3
0
        public void Test2()
        {
            //Arrange
            IOrderDAO x = Substitute.For <IOrderDAO>(); // mock for IOrderDAO
            IClient   y = Substitute.For <IClient>();   // MOCK FOR IClient

            Order   p = new Order(x, y);
            IFlower f = Substitute.For <IFlower>();

            f.Cost.Returns(20);
            IFlower ff = Substitute.For <IFlower>();

            ff.Cost.Returns(30);
            IFlower fff = Substitute.For <IFlower>();

            fff.Cost.Returns(10);
            p.AddFlowers(f, 1);
            p.AddFlowers(ff, 1);
            p.AddFlowers(fff, 1);

            //Act
            double price = p.Price;

            //Assert
            Assert.AreEqual((0.2 * 20) + (0.2 * 10) + (0.2 * 30), price);
        }
예제 #4
0
        public Order(IOrderDAO dao, IClient client)
        {
            this.flowers     = new List <IFlower>();
            this.isDelivered = isDelivered();
            Client           = Client;

            Id = dao.AddOrder(client);
        }
예제 #5
0
 /// <summary>
 /// Creates a new account controller.
 /// </summary>
 /// <param name="tokenGenerator">A token generator used when creating auth tokens.</param>
 /// <param name="passwordHasher">A password hasher used when hashing passwords.</param>
 /// <param name="userDao">A data access object to store user data.</param>
 public LoginController(ITokenGenerator tokenGenerator, IPasswordHasher passwordHasher, IUserDAO userDao, IEventDAO eventDAO, IOrderDAO orderDAO)
 {
     this.tokenGenerator = tokenGenerator;
     this.passwordHasher = passwordHasher;
     this.userDao        = userDao;
     this.eventDAO       = eventDAO;
     _orderDAO           = orderDAO;
 }
예제 #6
0
 public OrderManager(IContextContainer container)
     : base(container)
 {
     _orderDAO = new OrderDAO(container);
     _productDAO = new ProductDAO(container);
     _bonusDAO = new BonusDAO(container);
     _cartDAO = new ShoppingCartDAO(container);
     _addressInfoDAO = new AddressInfoDAO(container);
     _customerDAO = new CustomerDAO(container);
 }
예제 #7
0
 public OrderManager(IContextContainer container)
     : base(container)
 {
     _orderDAO       = new OrderDAO(container);
     _productDAO     = new ProductDAO(container);
     _bonusDAO       = new BonusDAO(container);
     _cartDAO        = new ShoppingCartDAO(container);
     _addressInfoDAO = new AddressInfoDAO(container);
     _customerDAO    = new CustomerDAO(container);
 }
        static DependencyResolver()
        {
            userDAO    = new UserDAO();
            orderDAO   = new OrderDAO();
            productDAO = new ProductDAO();

            userBL    = new UserBL(userDAO);
            orderBL   = new OrderBL(orderDAO);
            productBL = new ProductBL(productDAO);
        }
예제 #9
0
        public void Test1()
        {
            //ARRANGE
            IOrder    order = new Order();
            IOrderDAO a     = Substitute.For <IOrderDAO>();

            //ACT

            //ASSERT
            a.Received().SetDelivered();
        }
예제 #10
0
        public void Test1()
        {
            //ARRANGE
            IClient   c = Substitute.For <IClient>();
            IOrderDAO b = Substitute.For <IOrderDAO>();
            Order     a = Substitute.For <Order>(b, c);

            //ACT
            a.Deliver();
            //ASSERT
            b.Received().SetDelivered(a);
        }
예제 #11
0
        public void Test1()
        {
            //Arrange
            IOrderDAO x = Substitute.For <IOrderDAO>(); // mock for IOrderDAO
            IClient   y = Substitute.For <IClient>();   // MOCK FOR IClient
            IOrder    p = new Order(x, y);

            //Act
            p.Deliver();
            //Assert
            x.Received().SetDelivered(p);
        }
예제 #12
0
        public void TestDelivery()
        {
            //Arrange
            IClient   MockClient   = Substitute.For <IClient>();
            IOrderDAO MockOrderDAO = Substitute.For <IOrderDAO>();
            Order     x            = new Order(MockOrderDAO, MockClient);

            //Act
            x.Deliver();

            //Assert
            MockOrderDAO.Received().SetDelivered(x);
        }
예제 #13
0
        public void Test1()
        {
            //arrange
            IClient   c     = Substitude.For <IClient>();
            IOrderDAO o     = Substitude.For <IOrderDAO>();
            Order     order = new Order(c, o);

            //ACT
            order.deliver();
            //Assert
            o.Recieved().setDelivered(order);
            Assert.Pass();
        }
예제 #14
0
        public void Test1()
        {
            //ARRANGE==========================
            IClient       c = Substitute.For <IClient>();
            IOrderDAO     y = Substitute.For <IOrderDAO>();
            List <Flower> f = new List <Flower>();
            IOrder        o = new Order(y, c, false);

            //ACT==============================
            o.Deliver();
            //ASSERT===========================
            y.Received().SetDelivered(Arg.Any <IOrder>());
        }
예제 #15
0
        public void CheckDeliveries()
        {
            //ARRANGE
            IClient   newClient   = Substitute.For <IClient>();
            IOrderDAO newOrderDAO = Substitute.For <IOrderDAO>();
            Order     one         = new Order(newOrderDAO, newClient);

            //ACT
            one.Deliver();

            //ASSERT
            newOrderDAO.Received().SetDelivered(one);
        }
예제 #16
0
        public void Test1()
        {
            //Arrange
            IOrder    o = Substitute.For <IOrder>();
            IOrderDAO d = Substitute.For <IOrderDAO>();
            IOrder    o = new Order(y, c, false);

            //Act
            o.IsDelivered = true;

            //Assert
            d.Received().SetDelivered(Arg.Any <IOrder>());
        }
예제 #17
0
        public void DeliveryTest1()
        {
            //arrange
            IClient   MockingClient   = Substitute.For <IClient>();
            IOrderDAO MockingOrderDAO = Substitute.For <IOrderDAO>();
            Order     me = new Order(MockingOrderDAO, MockingClient);

            //Act
            me.Deliver();

            //Assert
            MockingOrderDAO.Received().SetDelivered(me);
            //Assert.Pass();
        }
예제 #18
0
        public void Test1()
        {
            //ARRANGE
            IClient   c   = Substitute.For <IClient>();
            IOrderDAO dao = Substitute.For <IOrderDAO>();
            IOrder    io  = Substitute.For <IOrder>();
            IOrder    o   = new Order(dao, c);

            //ACT
            o.Deliver(dao, io);

            //ASSERT
            dao.Received().SetDelivered(io);
        }
예제 #19
0
        public void Test1()
        {
            //ARRANGE
            IOrderDAO od = Substitute.For <IOrderDAO>();
            IClient   c  = Substitute.For <IClient>();
            IOrder    o  = new Order(od, c);

            // ACT

            o.Deliver();

            //ASSERT
            od.Received().SetDelivered(Arg.Is(o));
        }
예제 #20
0
        public void DeliverTests()
        {
            //Arrange
            IClient   x      = Substitute.For <IClient>();
            IOrderDAO order  = Substitute.For <IOrderDAO>();
            IOrder    number = Substitute.For <IOrder>();
            IOrder    nord   = new Order(dao, x);

            //Act
            nord.Deliever(order, number);

            //Assert
            order.SetDelivered(number);
        }
예제 #21
0
        public void TestPrice()
        {
            //Arrange
            IClient    MockClient    = Substitute.For <IClient>();
            IOrderDAO  MockOrderDAO  = Substitute.For <IOrderDAO>();
            IFlowerDAO MockFlowerDao = Substitute.For <IFlowerDAO>();
            Order      x             = new Order(MockOrderDAO, MockClient);
            Flower     MockFlower    = Substitute.For <Flower>(MockFlowerDao, "Not A Flower", 10.00, 5); //Base price of 10.00

            //Act
            x.AddFlowers(MockFlower);

            //Assert
            Assert.AreEqual(12.00, x.Price);
        }
예제 #22
0
        public void TestPrice()
        {
            //Arrange
            IClient    x      = Substitute.For <IClient>();
            IOrderDAO  order  = Substitute.For <IOrderDAO>();
            IOrder     number = Substitute.For <IOrder>();
            IFlowerDAO dao    = Substitute.For <IFlowerDAO>();
            Order      nord   = Substitute.For <Order>(dao, x);

            //Act
            Flower Tulip = Substitute.For <Flower>(dao, "Tulip", 200, 1);

            //Assert
            Assert.AreEqual(240, number.Price);
        }
예제 #23
0
        public void Test1()
        {
            //ARRANGE
            IClient   c = Substitute.For <IClient>();
            IOrderDAO y = Substitute.For <IOrderDAO>();
            IOrder    o = new Order(y, c, false);

            //ACT
            o.Deliver();

            //ASSERT
            y.SetDelivered(Arg.Any <IOrder>());

            //Assert.Pass();
        }
예제 #24
0
        public void Test2()
        {
            //ARRANGE==========================
            IClient   c = Substitute.For <IClient>();
            IOrderDAO y = Substitute.For <IOrderDAO>();
            IFlower   f = Substitute.For <IFlower>();
            IOrder    o = new Order(y, c, false);

            //ACT==============================
            o.AddFlowers(f, 3);
            double orderPrice = o.Price;

            //ASSERT===========================
            // Adding 3 flowers with 20% markup each (The way Price should work)
            Assert.AreEqual(orderPrice, 3 * 1.2 * f.Cost);
        }
예제 #25
0
        public void Test1()
        {
            // ARRANGE
            IClientDAO ns        = Substitute​.For <IClientDAO>();
            Client     newClient = new Client(ns, "Name", "0215005421540");

            IOrderDAO sd       = Substitute​.For <IOrderDAO>();
            Order     newOrder = new Order(sd, newClient);
            IOrder    order    = Substitute.For <IOrder>();

            // ACT
            newOrder.Deliver();

            // ASSERT
            Assert.AreEqual(2, sd.ReceivedCalls().Count());
        }
예제 #26
0
        public void Test1()
        {
            //Arrange
            IClient       c = Substitute.For <IClient>();
            IOrderDAO     a = Substitute.For <IOrderDAO>();
            List <Flower> f = new List <Flower>();
            IOrder        o = new Order(a, c, false);

            //Act
            o.Deliver();

            //Assert
            a.SetDelivered(Arg.Any <IOrder>());



            Assert.Pass();
        }
예제 #27
0
        public void Test2()
        {
            //ARRANGE
            IClient    c    = Substitute.For <IClient>();
            IOrderDAO  dao  = Substitute.For <IOrderDAO>();
            IOrder     io   = Substitute.For <IOrder>();
            Order      o    = Substitute.For <Order>(dao, c);
            IFlowerDAO fdao = Substitute.For <IFlowerDAO>();
            Flower     f    = Substitute.For <Flower>(fdao, "Rose", 100, 1);

            //ACT
            f = new Flower(fdao, "Rose", 100, 1);
            o = new Order(dao, c);
            o.AddFlowers(fdao, f, 1);

            //ASSERT
            Assert.AreEqual(120, o.Price);
        }
예제 #28
0
        /* public void Test1()
         * {
         *   //Arrange
         *   IOrderDAO orderDAO = Substitute.For<IOrderDAO>();
         *   IClient client = Substitute.For<IClient>();
         *   IOrder Order = Substitute.For<IOrder>();
         *   Order order = new Order(orderDAO, client);
         *
         *   //Act
         *   order.Deliver();
         *
         *   //Assert
         *   orderDAO.Received().SetDelivered(Arg.Any<IOrder>());
         * }
         */
        public void Test2()
        {
            //Arrange
            //IOrderDAO orderDAO = Substitute.For<IOrderDAO>();
            IFlowerDAO flowerDAO = Substitute.For <IFlowerDAO>();
            IClient    client    = Substitute.For <IClient>();
            IOrderDAO  Order     = Substitute.For <IOrderDAO>();
            Order      order     = Substitute.ForPartsOf <Order>(Order, client, false);
            var        flower    = Substitute.For <Flower>(flowerDAO, "Red", 274.99, 3);
            var        flower1   = Substitute.For <Flower>(flowerDAO, "White Roses", 129.99, 10);
            var        flower2   = Substitute.For <Flower>(flowerDAO, "SunFlower", 50, 30);

            //Act
            order.Price.Returns(30);

            //Assert
            Assert.That(order.Price, Is.EqualTo(30));
        }
예제 #29
0
        public void TestPrice()
        {
            //arrange
            IClient    MockingClient    = Substitute.For <IClient>();
            IOrderDAO  MockingOrderDAO  = Substitute.For <IOrderDAO>();
            IFlowerDAO MockingFlowerDAO = Substitute.For <IFlowerDAO>();
            Order      me            = new Order(MockingOrderDAO, MockingClient);
            IFlower    MockingFlower = Substitute.For <Flower>(MockingFlowerDAO, "ThisFlower", 12.00, 1); //Price of 12.00 Rand


            //Act
            //me.get(Price);
            //MockingFlower.get(Price);
            //me.Price(MockingFlower,1);
            me.AddFlowers(MockingFlower, 6); ///not sure what is wrong here. cant seem to get it to work. I get an error message with this line.

            //Assert
            Assert.AreEqual(14.40, me.Price);
        }
예제 #30
0
        public void Test1()
        {
            // Arrange
            //IOrderDAO o = new Order( 1049, Ana);

            IClient   c = Substitute.For <IClient>();
            IOrderDAO e = Substitute.For <IOrderDAO>();
            IOrder    s = new Order(e, c);


            //IOrderDAO orderMock = Mock.Create<IOrderDAO>();
            //x.Arrange(() => orderMock.SetDeliver(x).Returns(true));

            // Act
            s.Deliver();

            //Assert
            e.Received().SetDelivered(s);
        }
예제 #31
0
        public void Test2()
        {
            // ARRANGE
            IClientDAO ns        = Substitute​.For <IClientDAO>();
            Client     newClient = new Client(ns, "Name", "0215005421540");

            IOrderDAO sd       = Substitute​.For <IOrderDAO>();
            Order     newOrder = new Order(sd, newClient, false);
            IOrder    order    = Substitute.For <IOrder>();

            IFlowerDAO flo  = Substitute​.For <IFlowerDAO>();
            IFlower    mflo = Substitute​.For <IFlower>();

            mflo = new Flower(flo, "sjdnskjdb as", 100, 20);

            // ACT
            newOrder.AddFlowers(mflo, flo, 21);

            // ASSERT
            Assert.AreEqual(120, newOrder.Price);
        }
예제 #32
0
 public OrderService()
 {
     this.orderDAO = new OrderDAO();
 }