Exemplo n.º 1
0
        public async Task UserCannotRateIfUserAlreayRate()
        {
            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);

            var rateIsAllowed = service.IsRateAllowed(companyId, "UserId1");

            Assert.True(rateIsAllowed);

            await service.RateAsync(companyId, "UserId1", 3);

            var rateAllowed = service.IsRateAllowed(companyId, "UserId1");

            Assert.False(rateAllowed);
        }