コード例 #1
0
ファイル: UpdateTaskTests.cs プロジェクト: slobo80/WebSite
        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();
        }
コード例 #2
0
ファイル: DataHelper.cs プロジェクト: alexmaris/WebSite
        public static Event InsertEvent(InMemoryOCCDB context, string name)
        {
            var item = new Event
            {
                Name = name
            };

            context.Events.Add(item);
            return(item);
        }
コード例 #3
0
ファイル: DataHelper.cs プロジェクト: alexmaris/WebSite
        public static Track InsertTrack(InMemoryOCCDB context, string name, string description)
        {
            var item = new Track
            {
                Name        = name,
                Description = description
            };

            context.Tracks.Add(item);
            return(item);
        }
コード例 #4
0
ファイル: DataHelper.cs プロジェクト: alexmaris/WebSite
        public static Person InsertPerson(InMemoryOCCDB context, string firstName, string lastName)
        {
            var item = new Person
            {
                FirstName = firstName,
                LastName  = lastName
            };

            context.People.Add(item);
            return(item);
        }
コード例 #5
0
ファイル: DataHelper.cs プロジェクト: alexmaris/WebSite
        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);
        }
コード例 #6
0
        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);
            });
        }
コード例 #7
0
ファイル: GetSessionTests.cs プロジェクト: slobo80/WebSite
        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
        }