public async Task MontageRepository__GetMontageByIdAsync__NotFound() { var options = GetDbContextOptions(); // Arrange await using (var context = GetDdContext(options)) { context.Montages.Add(new Montage { Id = 1, Name = "name", Quantity = 10 }); context.Montages.Add(new Montage { Id = 2, Name = "name2", Quantity = 20 }); context.Montages.Add(new Montage { Id = 3, Name = "name3", Quantity = 30 }); await context.SaveChangesAsync(); } await using (var context = GetDdContext(options)) { // Act var montageRepository = new MontageRepository(context); var result = await montageRepository.GetByIdAsync(5); // Assert Assert.Null(result); } }
public async Task MontageRepository__GetMontageByIdAsync__GetResult() { // Arrange var options = GetDbContextOptions(); await using (var context = GetDdContext(options)) { context.Montages.Add(new Montage { Id = 1, Name = "name", Quantity = 10 }); context.Montages.Add(new Montage { Id = 2, Name = "name2", Quantity = 20 }); context.Montages.Add(new Montage { Id = 3, Name = "name3", Quantity = 30 }); await context.SaveChangesAsync(); } await using (var context = GetDdContext(options)) { // Act var montageRepository = new MontageRepository(context); var result = await montageRepository.GetByIdAsync(1); // Assert Assert.NotNull(result); Assert.AreEqual(1, result.Id); Assert.AreEqual("name", result.Name); Assert.AreEqual(10, result.Quantity); Assert.AreEqual(null, result.Nominal); } }