public async Task TestIfGetMostViewedProductsReturnsEmpty() { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var chartsService = new SupportChartsService(context); Assert.Empty(await chartsService.GetMostViewedProductsAsync()); }
public async Task TestIfGetMostViewedProductsWorksAccordingly(string title, int views) { var context = PCHUBDbContextInMemoryInitializer.InitializeContext(); var chartsService = new SupportChartsService(context); await context.Products.AddRangeAsync(new Product { Title = title, Views = views, }); await context.SaveChangesAsync(); var result = await chartsService.GetMostViewedProductsAsync(); Assert.NotEmpty(result); Assert.Contains(result, x => x.Views == views && x.Title == title); }