public void Should_OK_GetAllCats_When_Full_DataBase() { var options = new DbContextOptionsBuilder <CatMashDBContext>() .UseInMemoryDatabase(databaseName: "CatMashDB1") .Options; // Run the test against one instance of the context using (var context = new CatMashDBContext(options)) { context.TCat.Add(new TCat { CatUrl = "img1" }); context.TCat.Add(new TCat { CatUrl = "img2" }); context.TCat.Add(new TCat { CatUrl = "img3" }); var updateCount = context.SaveChanges(); Assert.Equal(3, updateCount); var catMashRepository = new CatMashRepository(context); var result = catMashRepository.GetAllCats(); Assert.NotNull(result); Assert.NotEmpty(result); Assert.Equal(3, result.Count()); } }
public void Should_OK_GetAllCats_When_Emty_DataBase() { var options = new DbContextOptionsBuilder <CatMashDBContext>() .UseInMemoryDatabase(databaseName: "CatMashDB2") .Options; // Run the test against one instance of the context using (var context = new CatMashDBContext(options)) { var catMashRepository = new CatMashRepository(context); var result = catMashRepository.GetAllCats(); Assert.NotNull(result); Assert.Empty(result); } }