Exemple #1
0
        public void Add_ClientOrderCorrectEntity_ReturnId()
        {
            // Arrange
            ClientOrderProvider clientOrderProvider = new ClientOrderProvider();
            var         allClientOrders             = clientOrderProvider.GetAll().OrderByDescending(p => p.Id);
            ClientOrder lastClientOrder             = allClientOrders.FirstOrDefault() ?? new ClientOrder();

            ClientOrderHandler clientOrderHandler = new ClientOrderHandler();
            ClientOrder        clientOrder        = new ClientOrder();

            clientOrder.ClientId     = "c983fea1-a550-4ea6-b45a-db66d9defcc1";
            clientOrder.DeliveryId   = 1;
            clientOrder.CreationDate = DateTime.Now;
            clientOrder.DeliveryDate = DateTime.Now;
            clientOrder.Orders       = new List <Order>()
            {
                new Order()
                {
                    ProductId = 1, Quantity = 1
                }
            };

            // Act
            int id = clientOrderHandler.Add(clientOrder);

            // Assert
            Assert.IsTrue(lastClientOrder.Id < id);
        }
Exemple #2
0
        public void Add_ClientOrderNull_ThrowsException()
        {
            // Arrange
            ClientOrderHandler clientOrderHandler = new ClientOrderHandler();
            ClientOrder        clientOrder        = null;

            // Act
            // Assert
            Assert.ThrowsException <NullReferenceException>(() => clientOrderHandler.Add(clientOrder));
        }