public async Task TwoRateFromSameUserShoiuldUpdateLastRate() { var companyId = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var mockRepository = new EfDeletableEntityRepository <Rate>(new ApplicationDbContext(options.Options)); var service = new RatingsService(mockRepository); await service.RateAsync(companyId, "UserId1", 3); await service.RateAsync(companyId, "UserId1", 5); var avgRates = await service.GetAvgCompanyRate(companyId); Assert.Equal(5.0, avgRates); }
public async Task ManyRatesFromDifferentUsersShoiuldReturnCorrectAverageRate() { var companyId = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var mockRepository = new EfDeletableEntityRepository <Rate>(new ApplicationDbContext(options.Options)); var service = new RatingsService(mockRepository); await service.RateAsync(companyId, "UserId1", 3); await service.RateAsync(companyId, "UserId2", 5); await service.RateAsync(companyId, "UserId3", 4); var avgRates = await service.GetAvgCompanyRate(companyId); Assert.Equal(4.0, avgRates); }