Ejemplo n.º 1
0
        public void RemovedOrderItemsDoesNotAppearInItemsProperty()
        {
            var order = new Order();
            var item  = new MockOrderItem();

            order.Add(item);
            order.Remove(item);
            Assert.DoesNotContain(item, order.Items);
        }
Ejemplo n.º 2
0
        public void AddedIOrderItemAppearInItemsProperty()
        {
            //Adding Something
            var order = new Order();
            var item  = new MockOrderItem();

            order.Add(item);
            Assert.Contains(item, order.Items);
        }
        public void RemovingOrderItemShouldInvokePropertyChangedForItemsPriceAndSubtotal(string propertyname)
        {
            var order = new Order();
            var item  = new MockOrderItem();

            Assert.PropertyChanged(order, propertyname, () =>
            {
                order.Remove(item);
            });
        }
        public async Task Should_Insert_And_Get_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            var result     = await repository.InsertAsync(MockOrderItem.GetEntityFake());

            Assert.NotNull(result);
            result = await repository.GetAsync(result.Id);

            Assert.NotNull(result);
        }
        public async Task Should_Return_All_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            await repository.InsertAsync(MockOrderItem.GetEntityFake());

            await repository.InsertAsync(MockOrderItem.GetEntityFake());

            var result = await repository.GetAll();

            Assert.Equal(2, result.ToList().Count);
        }
        public async Task Should_Delete_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            var result     = await repository.InsertAsync(MockOrderItem.GetEntityFake());

            Assert.NotNull(result);
            Assert.True(!result.IsExcluded);
            await repository.DeleteAsync(result);

            result = await repository.GetAsync(result.Id);

            Assert.True(result.IsExcluded);
        }
        public async Task Should_Return_All_by_OrderId_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            var item       = MockOrderItem.GetEntityFake();
            await repository.InsertAsync(item);

            item.OrderId = Guid.NewGuid();
            await repository.InsertAsync(item);

            var result = await repository.GetAllByOrderIdAsync(item.OrderId);

            Assert.Single(result.ToList());
        }
        public async Task Should_Return_All_Without_Disabled_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            await repository.InsertAsync(MockOrderItem.GetEntityFake());

            var disable = await repository.InsertAsync(MockOrderItem.GetEntityFake());

            disable.IsEnabled = false;
            await repository.UpdateAsync(disable);

            var result = await repository.GetAllWithoutDisable();

            Assert.Single(result.ToList());
        }
        public async Task Should_Update_Async()
        {
            var repository = MockOrderItem.GetDBTestRepository();
            var entity     = MockOrderItem.GetEntityFake();

            entity.Quantity = 500;
            var result = await repository.InsertAsync(entity);

            Assert.NotNull(result);
            result.Quantity = 400;
            await repository.UpdateAsync(result);

            result = await repository.GetAsync(result.Id);

            Assert.Equal(400, result.Quantity);
        }
Ejemplo n.º 10
0
        public async Task Should_Insert_And_GetOrder_And_GetOrderItem_Async()
        {
            var context        = MockDbContext.CreateDBInMemoryContext();
            var itemRepository = MockOrderItem.GetDBTestRepository(context);
            var repository     = MockOrder.GetDBTestRepository(context);
            var order          = MockOrder.GetEntityFake();
            var orderItem      = MockOrderItem.GetEntityFake();

            order.OrderItems = new List <OrderItem>
            {
                orderItem
            };
            var result = await repository.InsertAsync(order);

            Assert.NotNull(result);
            result = await repository.GetAsync(result.Id);

            Assert.NotNull(result);
            var orderItems = await itemRepository.GetAll();

            Assert.Single(orderItems);
        }
Ejemplo n.º 11
0
        public async Task Should_Delete_With_OrderItens_Async()
        {
            var context             = MockDbContext.CreateDBInMemoryContext();
            var applicationUserId   = Guid.NewGuid();
            var repository          = MockOrder.GetDBTestRepository(context);
            var orderItemRepository = MockOrderItem.GetDBTestRepository(context);
            var order = MockOrder.GetEntityFake();

            order.ApplicationUserId = applicationUserId;
            order.OrderItems        = new List <OrderItem>()
            {
                new OrderItem()
                {
                    Quantity = 100,
                    Price    = 1,
                    Fee      = 10,
                    FeeAsset = new Asset()
                }
            };
            order = await repository.InsertAsync(order);

            Assert.NotNull(order);
            Assert.True(!order.IsExcluded);
            Assert.True(!order.OrderItems.First().IsExcluded);
            var orderItems = await orderItemRepository.GetAllByOrderIdAsync(order.Id);

            Assert.True(orderItems.Any());
            await repository.DeleteAsync(order);

            order = await repository.GetAsync(order.Id);

            Assert.True(order.IsExcluded);
            orderItems = await orderItemRepository.GetAllByOrderIdAsync(order.Id);

            Assert.True(!orderItems.Any());
        }