public async Task Should_Load_Childs_In_Orders_By_Application_User_Async() { var context = MockDbContext.CreateDBInMemoryContext(); var applicationUserId = Guid.NewGuid(); var repository = MockOrder.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.BaseAsset = new Asset(); order.QuoteAsset = new Asset(); order.Exchange = new Exchange(); await repository.InsertAsync(order); await repository.InsertAsync(order); await repository.InsertAsync(MockOrder.GetEntityFake()); var result = await repository.GetAllByApplicationUserAsync(applicationUserId); Assert.Equal(2, result.Count); Assert.True(result.First().OrderItems.Any()); }
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); }
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()); }