public void TestInit() { Context.RemoveAllDbSetDataDatabase(); _sampleStatus = new Status() { Title = "Sample Title" }; }
public void Should_Populate_ID() { // arrange var newStatus = new Status(); // act Context.Statuses.Add(newStatus); Context.SaveChanges(); // assert Context.Statuses.First().Id.ShouldBe(1); }
public void Add_Status_With_Defaults() { //arrange var newStatus = new Status(); //act Context.Statuses.Add(newStatus); Context.SaveChanges(); //assert int rowCount = Context.Statuses.Count(); rowCount.ShouldBeGreaterThan(0); }
public void Should_Not_Allow_Duplicate_ID() { // arrange Context.Statuses.Add(_sampleStatus); Context.SaveChanges(); Status duplicateStatus = new Status { Id = 1, Title = "Unique Status" }; // act Context.Statuses.Add(duplicateStatus); Context.SaveChanges(); Status correctedDuplicateStatus = Context.Statuses.First(e => e.Title == "Unique Status"); // assert correctedDuplicateStatus.Id.ShouldNotBe(1); }
public void Delete_Status() { //arrange var newStatus = new Status(); //act Context.Statuses.Add(newStatus); Context.SaveChanges(); Context.Statuses.Remove(newStatus); Context.SaveChanges(); //assert int rowCount = Context.Statuses.Count(); rowCount.ShouldBe(0); }
public void Update_Status_From_Defaults() { // arrange var newStatus = new Status() { Title = "Sample Status" }; Context.Statuses.Add(newStatus); Context.SaveChanges(); Status oldStatus = Context.Statuses.First(e => e.Title == "Sample Status"); oldStatus.Title = "New Status"; var oldId = oldStatus.Id; //act Context.Entry(oldStatus).State = EntityState.Modified; Context.SaveChanges(); //assert Status modifiedStatus = Context.Statuses.Find(oldId); modifiedStatus.Title.ShouldBe("New Status"); }