public void TestInit() { Context.RemoveAllDbSetDataDatabase(); _sampleEventType = new EventType() { Title = "Sample EventType" }; }
public void Should_Populate_ID() { // arrange var newEventType = new EventType(); // act Context.EventType.Add(newEventType); Context.SaveChanges(); // assert Context.EventType.First().Id.ShouldBe(1); }
public void Add_EventType_With_Defaults() { //arrange var newEventType = new EventType(); //act Context.EventType.Add(newEventType); Context.SaveChanges(); //assert int rowCount = Context.EventType.Count(); rowCount.ShouldBeGreaterThan(0); }
public void Should_Not_Allow_Duplicate_ID() { // arrange Context.EventType.Add(_sampleEventType); Context.SaveChanges(); EventType duplicateEventType = new EventType { Id = 1, Title = "Unique EventType" }; // act Context.EventType.Add(duplicateEventType); Context.SaveChanges(); EventType correctedDuplicateEventType = Context.EventType.First(e => e.Title == "Unique EventType"); // assert correctedDuplicateEventType.Id.ShouldNotBe(1); }
public void AutoIncrement_Reset() { //arrange var newEventType = new EventType() { }; //act Context.EventType.Add(newEventType); Context.EventType.Add(newEventType); Context.EventType.Add(newEventType); Context.SaveChanges(); Context.RemoveDbSetDataDatabase(Context.EventType); Context.EventType.Add(newEventType); Context.SaveChanges(); //assert Context.EventType.Count().ShouldBe(1); Context.EventType.First().Id.ShouldBe(1); }
public void Delete_EventType() { //arrange var newEventType = new EventType(); //act Context.EventType.Add(newEventType); Context.SaveChanges(); Context.EventType.Remove(newEventType); Context.SaveChanges(); //assert int rowCount = Context.EventType.Count(); rowCount.ShouldBe(0); }
public void Update_EventType_From_Defaults() { // arrange var newEventType = new EventType() { Title = "Sample Status" }; Context.EventType.Add(newEventType); Context.SaveChanges(); EventType oldEventType = Context.EventType.First(e => e.Title == "Sample Status"); oldEventType.Title = "New Status"; var oldId = oldEventType.Id; //act Context.Entry(oldEventType).State = EntityState.Modified; Context.SaveChanges(); //assert EventType modifiedEventType = Context.EventType.Find(oldId); modifiedEventType.Title.ShouldBe("New Status"); }
public void Add_Event_With_Nonexistent_FK() { //arrange var newEventType = new EventType() { Title = "EventType Title" }; _sampleEvent.EventType = newEventType; //act Context.Events.Add(_sampleEvent); Context.SaveChanges(); //assert Context.EventType.ShouldContain(newEventType); }
public void Add_Event_With_Existing_FK() { //arrange var newEventType = new EventType(); Context.EventType.Add(newEventType); Context.SaveChanges(); _sampleEvent.EventType = newEventType; //act Context.Events.Add(_sampleEvent); Context.SaveChanges(); //assert Context.Events.Find(1).EventType.Id.ShouldBe(1); }
public void Add_Event_With_ForeignKeys() { // arrange var newEventType = new EventType() { Title = "new event" }; Context.EventType.Add(newEventType); Context.SaveChanges(); _sampleEvent.EventType = newEventType; // act Context.Events.Add(_sampleEvent); Context.SaveChanges(); //assert Context.Events.Count().ShouldBeGreaterThan(0); Context.Events.Find(1).ShouldBe(_sampleEvent); Context.Events.Find(1).EventType.ShouldBe(newEventType); }
public void Add_Registration_With_Nonexistent_FK() { //arrange var newEventType = new EventType() { Title = "EventType Title" }; Context.EventType.Add(newEventType); Context.SaveChanges(); var newEvent = new Event { Title = "Sample Event", Description = "Sample Event Description", StartDateTime = DateTime.Now, EndDateTime = DateTime.Now.AddHours(1), Category = new Category(), Registrations = new List<Registration>(), EventType = newEventType, Status = new Status(), LocationInformation = "At some new location", LogoPath = "http://google/someimage" }; Context.Events.Add(newEvent); Context.SaveChanges(); var newRegistration = new Registration() { Event = newEvent, EventType = newEventType, RegisterDateTime = DateTime.Now, Title = "A title" }; //act Context.Registrations.Add(newRegistration); Context.SaveChanges(); //assert Context.EventType.ShouldContain(newEventType); }