Exemplo n.º 1
0
        public async Task AddAsync_ShouldAddOrder()
        {
            var orderRepository = InitializeRepository();

            var order = new Order
            {
                CreationDate = DateTime.Now,
                UserId       = 1,
                Products     = new List <ProductOrder>
                {
                    new ProductOrder
                    {
                        ProductId  = 1,
                        UnityPrice = 10.20M,
                        Quantity   = 10
                    }
                }
            };

            var result = await orderRepository.AddAsync(order);

            context.DropCommerceContext();
            Assert.NotNull(result);
            Assert.NotEqual(0, result.Id);
            Assert.Equal(order.UserId, result.UserId);
            Assert.NotEmpty(result.Products);
        }
Exemplo n.º 2
0
        public async Task AddAsync_ShouldAddProduct()
        {
            var productRepository = InitializeRepository();

            var product = new Product
            {
                CreationDate = DateTime.Now,
                Description  = "newDescription",
                Name         = "Product add test",
                Price        = 2M
            };

            var result = await productRepository.AddAsync(product);

            var addedProduct = context.CommerceContext().Products.FirstOrDefault(u => u.Name.Equals(product.Name));

            context.DropCommerceContext();
            Assert.NotNull(addedProduct);
            Assert.NotEqual(0, addedProduct.Id);
            Assert.Equal(product.Name, addedProduct.Name);
            Assert.Equal(product.Description, addedProduct.Description);
            Assert.Equal(product.Price, addedProduct.Price);
            Assert.Equal(product.CreationDate, addedProduct.CreationDate);
        }
Exemplo n.º 3
0
        public void GetUsers_ShouldReturnListOfAllUsers()
        {
            var userRepository = InitializeRepository();
            var users          = context.CommerceContext().Users;

            var result = userRepository.GetUsers(new GetUsersRequest());

            context.DropCommerceContext();
            Assert.Equal(users.ToList(), result.OrderBy(r => r.Id));
        }