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(); }
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); }