Beispiel #1
0
        public async Task IncorrectRateShoiuldReturnZeroCount()
        {
            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(1, "UserId", 6);

            await service.RateAsync(1, "UserId", 0);

            var rates = service.GetAllCount();

            Assert.Equal(0, rates);
        }
Beispiel #2
0
        public async Task TwoRatesFromDifferentUsersShoiuldCountTwoTimes()
        {
            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(1, "UserId1", 3);

            await service.RateAsync(1, "UserId2", 3);

            var rates = service.GetAllCount();

            Assert.Equal(2, rates);
        }