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 }
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 static InMemoryOCCDB WithTask(this InMemoryOCCDB context, string description = "Test Description") { DataHelper.InsertTask(context, description); context.SaveChanges(); return(context); }
public static InMemoryOCCDB WithEvent(this InMemoryOCCDB context, string name) { DataHelper.InsertEvent(context, name); context.SaveChanges(); return(context); }
public static InMemoryOCCDB WithPerson(this InMemoryOCCDB context, string firstName, string lastName) { DataHelper.InsertPerson(context, firstName, lastName); context.SaveChanges(); return(context); }