public void WhenUpdatingTaskPropertiesAreSavedCorrectly() { // Assemble var dbContext = new InMemoryOCCDB() .WithEvent("Test Event") .WithEvent("Second Event") .WithTask("Test Task"); _expectedTask = new Services.Task { Description = "This is the Modified Task", Capacity = 5, StartTime = DateTime.Today, EndTime = DateTime.Now, EventID = 2 }; var service = TestHelper.GetTestService(dbContext); var originalTask =service.GetTaskById(1); originalTask.Description = _expectedTask.Description; originalTask.Capacity = _expectedTask.Capacity; originalTask.StartTime = _expectedTask.StartTime; originalTask.EndTime = _expectedTask.EndTime; originalTask.EventID = _expectedTask.EventID; // Act service.UpdateTask(originalTask); // Assert _actualTask = dbContext.Tasks.First(); }
public static Event InsertEvent(InMemoryOCCDB context, string name) { var item = new Event { Name = name }; context.Events.Add(item); return(item); }
public static Track InsertTrack(InMemoryOCCDB context, string name, string description) { var item = new Track { Name = name, Description = description }; context.Tracks.Add(item); return(item); }
public static Person InsertPerson(InMemoryOCCDB context, string firstName, string lastName) { var item = new Person { FirstName = firstName, LastName = lastName }; context.People.Add(item); return(item); }
public static Data.Task InsertTask(InMemoryOCCDB context, string description) { var @event = context.Events.First(); var task = new Data.Task { Description = description, Event_ID = @event.ID }; context.Tasks.Add(task); return(task); }
public void WhenGettingSpeakerSessionsOnlySessionsForThatSpeakerAreReturned() { var speaker1FirstName = "Test"; var speaker1LastName = "Speaker"; var speaker1SessionNames = "Sessions by Speaker 1"; var speaker2FirstName = "Other"; var speaker2LastName = "Presenter"; var speaker2SessionNames = "Sessions by Speaker 2"; // Assemble var dbContext = new InMemoryOCCDB() .WithEvent("Test Code Camp") .WithPerson(speaker1FirstName, speaker1LastName) .WithPerson(speaker2FirstName, speaker2LastName); var @event = dbContext.Events.First(); var speaker1 = dbContext.People.First(p => p.FirstName.Equals(speaker1FirstName) && p.LastName.Equals(speaker1LastName)); var speaker2 = dbContext.People.First(p => p.FirstName.Equals(speaker2FirstName) && p.LastName.Equals(speaker2LastName)); var sessions = new[] { new Data.Session { Event_ID = @event.ID, Name = speaker1SessionNames, Speaker_ID = speaker1.ID, }, new Data.Session { Event_ID = @event.ID, Name = speaker1SessionNames, Speaker_ID = speaker1.ID, }, new Data.Session { Event_ID = @event.ID, Name = speaker1SessionNames, Speaker_ID = speaker1.ID, }, new Data.Session { Event_ID = @event.ID, Name = speaker2SessionNames, Speaker_ID = speaker2.ID, }, new Data.Session { Event_ID = @event.ID, Name = speaker2SessionNames, Speaker_ID = speaker2.ID, } }; sessions.ForEach(s=>dbContext.Sessions.Add(s)); dbContext.SaveChanges(); var service = TestHelper.GetTestService(dbContext); // Act var speaker2Sessions = service.GetSpeakerSessions(@event.ID,speaker2.ID); // Assert Assert.AreEqual(speaker2Sessions.Count(), 2); speaker2Sessions.ForEach(s => { Assert.AreEqual(s.Name,speaker2SessionNames); }); }
public void WhenGettingSessionPropertiesAreRetrievedCorrectly() { // Assemble var dbContext = new InMemoryOCCDB() .WithEvent("Test Code Camp") .WithPerson("Test", "Speaker"); _expectedEvent = dbContext.Events.First(); _expectedSpeaker = dbContext.People.First(); _expectedSession = new Data.Session { Description = "This is the event", Event_ID = _expectedEvent.ID, Level = 300, Location = "The really far building", Name = "Best .NET Session", Speaker_ID = _expectedSpeaker.ID, Status = "Still Happening", }; dbContext.Sessions.Add(_expectedSession); dbContext.SaveChanges(); var service = TestHelper.GetTestService(dbContext); // Act _actualSession = service.GetSession(_expectedSession.ID); // Assert }