public void TestInit() { Context.RemoveAllDbSetDataDatabase(); _sampleCategory = new Category() { Title = "Sample Category" }; }
public void Should_Populate_ID() { // arrange var newCategory = new Category(); // act Context.Category.Add(newCategory); Context.SaveChanges(); // assert Context.Category.First().Id.ShouldBe(1); }
public void Add_Category_With_Defaults() { //arrange var newCategory = new Category(); //act Context.Category.Add(newCategory); Context.SaveChanges(); //assert int rowCount = Context.Category.Count(); rowCount.ShouldBeGreaterThan(0); }
public void Delete_Category() { //arrange var newCategory = new Category(); //act Context.Category.Add(newCategory); Context.SaveChanges(); Context.Category.Remove(newCategory); Context.SaveChanges(); //assert int rowCount = Context.Category.Count(); rowCount.ShouldBe(0); }
public void Should_Not_Allow_Duplicate_ID() { // arrange Context.Category.Add(_sampleCategory); Context.SaveChanges(); Category duplicateCategory = new Category { Id = 1, Title = "Unique Category" }; // act Context.Category.Add(duplicateCategory); Context.SaveChanges(); Category correctedDuplicateCategory = Context.Category.First(e => e.Title == "Unique Category"); // assert correctedDuplicateCategory.Id.ShouldNotBe(1); }