Exemple #1
0
        public void AddOrderAlreadyInDatabaseTest()
        {
            //init db
            UnitOfWork       uow    = new UnitOfWork(new KlantenBestellingenTestContext(false));
            DomainController dc     = new DomainController(uow);
            Client           client = new Client("TestName", "Test5678910");

            dc.AddClient(client);
            //
            Client gettedClient = dc.GetClient(1);
            Order  order        = new Order(Product.Duvel, 10, gettedClient);

            dc.AddOrder(order, gettedClient.Id);
            Action act = () => dc.AddOrder(order, gettedClient.Id);

            act.ShouldNotThrow();
            Order changedOrder = dc.GetOrder(1);

            changedOrder.Amount.ShouldBe(20);
        }
Exemple #2
0
        public void DeleteOrderNoExceptionTest()
        {
            //init db
            UnitOfWork       uow    = new UnitOfWork(new KlantenBestellingenTestContext(false));
            DomainController dc     = new DomainController(uow);
            Client           client = new Client("TestName", "Test5678910");

            dc.AddClient(client);
            //
            Client gettedClient = dc.GetClient(1);
            Order  order        = new Order(Product.Duvel, 10, gettedClient);

            dc.AddOrder(order, gettedClient.Id);
            Action act = () => dc.DeleteOrder(1);

            act.ShouldNotThrow();
            act = () => dc.GetOrder(1);
            act.ShouldThrow <Exception>().Message.ShouldBe("Order not in database.");
        }
Exemple #3
0
        public void IntegratieTest()
        {
            UnitOfWork       uow = new UnitOfWork(new KlantenBestellingenTestContext(false));
            DomainController dc  = new DomainController(uow);
            Action           act = () =>
            {
                Client client  = new Client("TestName", "Test5678910");
                Client client2 = new Client("Test2", "Tralalalalallalalal");
                dc.AddClient(client);
                dc.AddClient(client2);
                Client gettedClient = dc.GetClient(2);
                dc.DeleteClient(gettedClient.Id);
                Client gettedClient2 = dc.GetClient(1);
                gettedClient2.Name = "Testeroo";
                dc.UpdateClient(gettedClient2);
                dc.AddClient(client2);
                Client gettedClient3 = dc.GetClient(3);
                dc.AddOrder(new Order(Product.Duvel, 10, gettedClient3), gettedClient3.Id);
            };

            act.ShouldNotThrow();
        }
Exemple #4
0
        public void UpdateOrderNoExceptionTest()
        {
            //init db
            UnitOfWork       uow    = new UnitOfWork(new KlantenBestellingenTestContext(false));
            DomainController dc     = new DomainController(uow);
            Client           client = new Client("TestName", "Test5678910");

            dc.AddClient(client);
            //
            Client gettedClient = dc.GetClient(1);
            Order  order        = new Order(Product.Duvel, 10, gettedClient);

            dc.AddOrder(order, gettedClient.Id);
            Order toUpdateOrder = dc.GetOrder(1);

            toUpdateOrder.Product = Product.Westmalle;
            Order  updatedOrder = null;
            Action act          = () => updatedOrder = dc.UpdateOrder(toUpdateOrder);

            act.ShouldNotThrow();
            updatedOrder.Product.ShouldBe(Product.Westmalle);
        }