public async Task MontageRepository__UpdateMontage() { var options = GetDbContextOptions(); // Arrange await using (var context = GetDdContext(options)) { context.Montages.Add(new Montage { Id = 1, Name = "name", Quantity = 10 }); await context.SaveChangesAsync(); } // Act await using (var context = GetDdContext(options)) { var montageRepository = new MontageRepository(context); montageRepository.UpdateAsync(new Montage { Id = 1, Name = "name123", Quantity = 15, Nominal = "nominal" }); await montageRepository.SaveAsync(); var montage = await context.Montages.FirstOrDefaultAsync(); // Assert Assert.NotNull(montage); Assert.AreEqual(1, montage.Id); Assert.AreEqual("name123", montage.Name); Assert.AreEqual(15, montage.Quantity); Assert.AreEqual("nominal", montage.Nominal); } }
public async Task MontageRepository__DeleteMontage() { var options = GetDbContextOptions(); // Arrange await using (var context = GetDdContext(options)) { context.Montages.Add(new Montage { Id = 1, Name = "name", Quantity = 10 }); await context.SaveChangesAsync(); } // Act await using (var context = GetDdContext(options)) { var montageRepository = new MontageRepository(context); montageRepository.Delete(new Montage { Id = 1 }); await montageRepository.SaveAsync(); var montage = await context.Montages.FirstOrDefaultAsync(); // Assert Assert.Null(montage); } }
public async Task MontageRepository__CreateMontage() { var options = GetDbContextOptions(); // Arrange await using var context = GetDdContext(options); // Act var montageRepository = new MontageRepository(context); await montageRepository.CreateAsync(new Montage { Id = 1, Name = "name", Quantity = 10 }); await montageRepository.SaveAsync(); // Assert Assert.IsNotEmpty(context.Montages); var montage = await context.Montages.FirstOrDefaultAsync(); Assert.NotNull(montage); Assert.AreEqual(1, montage.Id); Assert.AreEqual("name", montage.Name); Assert.AreEqual(10, montage.Quantity); Assert.AreEqual(null, montage.Nominal); }