예제 #1
0
        public void CallingRemoveAttendanceSucceedsWhenTheAttendanceDoesNotExist()
        {
            // Arrange
            var happening = new EventBuilder().AddAttendance(_attendance).Build();

            happening.AddAttendance(new AttendanceBuilder().Build());
            happening.AddAttendance(new AttendanceBuilder().Build());

            // Act
            happening.RemoveAttendance(new UserBuilder().Build());

            // Assert
            Assert.AreEqual(3, happening.Attendances.Count);
        }
예제 #2
0
        public void CallingRemoveAttendanceRemovesTheCorrectAttendanceWhenTheAttandanceExistsByReference()
        {
            // Arrange
            var user      = new UserBuilder().Build();
            var happening = new EventBuilder().AddAttendance(_attendance).Build();

            happening.AddAttendance(new AttendanceBuilder().User(user).Build());
            happening.AddAttendance(new AttendanceBuilder().Build());

            // Act
            happening.RemoveAttendance(user);

            // Assert
            Assert.AreEqual(2, happening.Attendances.Count);
            Assert.IsNull(happening.Attendances.FirstOrDefault(a => a.User.Username == user.Username));
        }
예제 #3
0
        public void TheEventStartDateIsNotUpdatedWithAnLaterAttendanceIsAdded()
        {
            // Arrange
            var attendance      = new AttendanceBuilder().Arrival(DateTime.Now).Build();
            var laterAttendance = new AttendanceBuilder().Arrival(DateTime.Now.AddHours(Randomiser.Int(20))).Departure(DateTime.Now.AddHours(Randomiser.Int(21, 60))).Build();
            var happening       = new EventBuilder().AddAttendance(attendance).Build();

            // Act
            happening.AddAttendance(laterAttendance);

            // Assert
            Assert.AreEqual(attendance.Arrival, happening.Start);
        }
예제 #4
0
        public void CallingAddAttendanceAddsTheCorrectAttendanceWhenTheAttandanceDoesNotExist()
        {
            // Arrange
            var user       = new UserBuilder().Build();
            var attendance = new AttendanceBuilder().Build();
            var happening  = new EventBuilder().AddAttendance(attendance).Build();

            // Act
            happening.AddAttendance(new AttendanceBuilder().User(user).Build());

            // Assert
            Assert.AreEqual(2, happening.Attendances.Count);
            Assert.IsNotNull(happening.Attendances.FirstOrDefault(a => a.User.Username == user.Username));
        }
예제 #5
0
        public void TheEventStartDateIsUpdatedWithAnEarlierAttendanceIsAdded()
        {
            // Arrange

            var attendance        = new AttendanceBuilder().Arrival(DateTime.Now).Build();
            var earlierAttendance = new AttendanceBuilder().Arrival(DateTime.Now.AddHours(-Randomiser.Int(60))).Build();
            var happening         = new EventBuilder().AddAttendance(attendance).Build();

            // Act
            happening.AddAttendance(earlierAttendance);

            // Assert
            Assert.AreEqual(earlierAttendance.Arrival, happening.Start);
        }
예제 #6
0
        public void TheEventEndDateIsUpdatedWithALaterAttendanceIsAdded()
        {
            // Arrange
            var user              = new UserBuilder().Build();
            var attendance        = new AttendanceBuilder().User(user).Arrival(DateTime.Now).Build();
            var happening         = new EventBuilder().AddAttendance(attendance).Build();
            var earlierAttendance = new AttendanceBuilder().User(user).Arrival(DateTime.Now.AddHours(-Randomiser.Int(60))).Build();

            // Act
            happening.AddAttendance(earlierAttendance);

            // Assert
            Assert.AreEqual(earlierAttendance.Departure, happening.End);
        }
예제 #7
0
        public void CallingAddAttendanceTwiceByUsernameOnlyAddsTheAttendanceOnceAndUpdatesTheArrivalAndDeparture()
        {
            // Arrange
            var user       = new UserBuilder().Build();
            var arrival1   = DateTime.Now;
            var departure1 = arrival1.AddMinutes(20);
            var arrival2   = arrival1.AddMinutes(Randomiser.Int(10));
            var departure2 = arrival2.AddMinutes(Randomiser.Int(10, 60));
            var attendance = new AttendanceBuilder().User(user).Arrival(arrival1).Departure(departure1).Build();

            // Act
            var happening = new EventBuilder().AddAttendance(attendance).Build();

            happening.AddAttendance(new AttendanceBuilder().User(new UserBuilder().Username(user.Username).Build()).Arrival(arrival2).Departure(departure2).Build());

            // Assert
            Assert.AreEqual(1, happening.Attendances.Count);
            Assert.AreEqual(arrival2, happening.Start);
            Assert.AreEqual(departure2, happening.End);
        }