public void CreateTest() { //Arrange Database db = new Database(); db.Database.Delete(); //Act bool created; Action act = () => created = db.Database.CreateIfNotExists(); //Assert act.ShouldThrow <InvalidOperationException>("Migrations are enabled so a simple create should fail"); }
public void AddDataTest() { //Arrange Database db = new Database(); Animal expectedAnimal = new Animal { Name = "Allan", Species = "dog", Legs = 2, Edible = true }; db.Database.ExecuteSqlCommand(@"DELETE FROM ""ANIMAL"".""Animals"""); //Act db.Animals.Add(expectedAnimal); Action act = () => db.SaveChanges(); //Assert act.ShouldNotThrow(); db.Animals.Find(expectedAnimal.Name).Should().NotBeNull(); }