public void CreateEventsFor_Test()
        {
            // Arrange
            _eventRepo.Setup(x => x.GetEventsOn(It.IsAny<DateTime>())).Returns(new List<Event>());
            var start = new DateTime(2014, 2, 16);
            // start.DayOfWeek = Sunday
            var end = start.AddDays(6);

            var basketball = new Activity
            {
                DayOfWeek = "Saturday",
                Name = "Basketball"
            };

            var frisbee = new Activity
            {
                DayOfWeek = "Sunday",
                Name = "Frisbee"
            };

            var activities = new List<Activity> {
                basketball, frisbee
            };

            var count = 0;
            _eventRepo.Setup(x => x.Insert(It.IsAny<Event>())).Callback((Event ev) => { count++; });
            _activtyRepo.Setup(x => x.GetAll()).Returns(activities);

            // Act
            _sut.CreateEventsFor(start, end);

            // Assert
            Assert.AreEqual(2, count);
        }
Exemplo n.º 2
0
        public void ActivityDTOTest()
        {
            Location location = new Location()
            {
                Name = "asdf",
                Address = "zxvc",
                LocationID = 1
            };

            Activity activity = new Activity()
            {
                ActivityID = 1,
                Name = "asdf",
                DayOfWeek = "Thursday",
                PreferredTime = new TimeSpan(1),
                Location = location
            };

            var dto = new ActivityDTO(activity);

            AssertActivityDTO(activity, dto);
        }
        public void GenerateEventsForActivitiesAndDateRange_Week_Test()
        {
            // Arrange
            _eventRepo.Setup(x => x.GetEventsOn(It.IsAny<DateTime>())).Returns(new List<Event>());
            var start = DateTime.Today;
            var end = start.AddDays(6);

            var basketball = new Activity {
                DayOfWeek = "Tuesday",
                Name = "Basketball"
            };

            var frisbee = new Activity {
                DayOfWeek = "Thursday",
                Name = "Frisbee"
            };

            var activites = new List<Activity> {
                basketball, frisbee
            };

            // Act
            var events = _sut.GenerateEventsForActivitiesAndDateRange(activites, start, end);

            // Assert
            Assert.AreEqual(2, events.Count);
        }
        public void GenerateEventsForActivitiesAndDateRange_SingleDay_Test()
        {
            // Arrange
            _eventRepo.Setup(x => x.GetEventsOn(It.IsAny<DateTime>())).Returns(new List<Event>());
            var start = new DateTime(2014, 2, 16);
            // start.DayOfWeek = Sunday
            var end = start;

            var basketball = new Activity
            {
                DayOfWeek = "Sunday",
                Name = "Basketball"
            };

            var frisbee = new Activity
            {
                DayOfWeek = "Sunday",
                Name = "Frisbee"
            };

            var activites = new List<Activity> {
                basketball, frisbee
            };

            // Act
            var events = _sut.GenerateEventsForActivitiesAndDateRange(activites, start, end);

            // Assert
            Assert.AreEqual(2, events.Count);
        }
        public void DoesEventExistTrueTest()
        {
            var selectedDate = DateTime.Today;

            // Arrange
            var activity = new Activity {
                Name = "Test",
            };

            var activity2 = new Activity {
                Name = "Test2",
            };

            var ev1 = new Event {
                Name = activity.Name,
                Activity = activity,
                DateTime = selectedDate
            };

            var ev2 = new Event {
                Name = activity.Name,
                Activity = activity2,
                DateTime = selectedDate
            };

            IEnumerable<Event> events = new List<Event> {
                ev1, ev2
            };

            _eventRepo.Setup(x => x.GetEventsOn(selectedDate)).Returns(events);

            // Act
            var does = _sut.DoesEventExistForActivityAndDate(activity, selectedDate);

            // Assert
            Assert.IsTrue(does);
        }
        public void DoesEventExistFalseTest()
        {
            var selectedDate = DateTime.Today;

            // Arrange
            var activity = new Activity
            {
                Name = "Test",
                ActivityID = 1
            };

            var activity2 = new Activity
            {
                Name = "Test2",
                ActivityID = 2
            };

            var activity3 = new Activity
            {
                Name = "Test3",
                ActivityID = 3
            };

            var ev1 = new Event
            {
                Activity = activity
            };

            var ev2 = new Event
            {
                Activity = activity2
            };

            IEnumerable<Event> events = new List<Event> {
                ev1, ev2
            };

            _eventRepo.Setup(x => x.GetEventsOn(selectedDate)).Returns(events);

            // Act
            var does = _sut.DoesEventExistForActivityAndDate(activity3, selectedDate);

            // Assert
            Assert.IsFalse(does);
        }
Exemplo n.º 7
0
        public void EventDTOTest()
        {
            Location location = new Location()
            {
                Name = "asdf",
                Address = "zxvc",
                LocationID = 1
            };

            Activity activity = new Activity()
            {
                ActivityID = 1,
                Name = "asdf",
                DayOfWeek = "Thursday",
                PreferredTime = new TimeSpan(1),
                Location = location
            };

            User user = new User()
            {
                Name = "kevin"
            };

            Guest guest = new Guest()
            {
                Name = "kevin",
                Host = user
            };

            Event ev = new Event()
            {
                Activity = activity,
                ActivityID = activity.ActivityID,
                UsersInEvent = new List<User>()
                {
                    user
                },
                GuestsInEvent = new List<Guest>()
                {
                    guest
                },
                DateTime = new DateTime(),
                EventID = 1,
                Name = "asdf"
            };

            var dto = new EventDTO(ev);

            AssertEventDTO(ev, dto);

            Assert.AreEqual(1, dto.UsersInEvent.Count());
            Assert.AreEqual(1, dto.GuestsInEvent.Count());
        }
Exemplo n.º 8
0
 private void AssertActivityDTO(Activity activity, ActivityDTO dto)
 {
     AssertDTO(activity, dto, new[] { "ActivityID", "Name", "DayOfWeek", "PreferredTime" });
     AssertLocationDTO(activity.Location, new LocationDTO(activity.Location));
 }
Exemplo n.º 9
0
 public ActivityDTO(Activity activity)
     : base(activity)
 {
     //Location = new LocationDTO(activity.Location);
 }
Exemplo n.º 10
0
        public bool DoesEventExistForActivityAndDate(Activity activity, DateTime date)
        {
            var exists = _eventRepo.GetEventsOn(date.Date);

            return (exists.Where<Event>(x => x.ActivityID.Equals(activity.ActivityID)).Count() > 0);
        }