Ejemplo n.º 1
0
        public async Task ShouldContainWhenAdd()
        {
            await _notificationQuery.AddNotification(
                new ApiNotificationResponseModel <string>("test"){ Type = ApiNotificationType.Welcome });

            var testNotification =
                await _dbContext.Notifications.FirstOrDefaultAsync(p =>
                                                                   p.Content.Contains("test"));

            Assert.IsNotNull(testNotification);

            _dbContext.Notifications.Remove(testNotification);
            await _dbContext.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task AddNotification_DbUpdateConcurrencyException()
        {
            IsCalledDbUpdateConcurrency = false;
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "MovieListDatabase")
                          .Options;

            var fakeQuery = new NotificationQuery(new AppDbContextConcurrencyException(options), new FakeIWebLogger());
            await fakeQuery.AddNotification("");

            Assert.IsTrue(IsCalledDbUpdateConcurrency);
        }