public void GetOrders_ShouldReturnListOfOrdersFilteredByUserName() { var request = new GetOrderRequest { Username = "******" }; var orderRepository = InitializeRepository(); var orders = context.CommerceContext().Orders .Where(u => u.User.Username.ToLower().Equals(request.Username.ToLower())); var result = orderRepository.GetOrders(request); context.DropCommerceContext(); Assert.Equal(orders, result); }
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)); }
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); }
private IOrderRepository InitializeRepository() { context = new MockCommerceContext(dataBaseName); return(new OrderRepository(context.CommerceContext())); }