Пример #1
0
        public void TestPerformanceCalendar()
        {
            Activity testActivity = new Activity();
            testActivity.DaysPerformedList = new List<DayOfWeek>
            {
                DayOfWeek.Friday,
                DayOfWeek.Tuesday,
                DayOfWeek.Wednesday
            };

            testActivity.Performances = new List<ActivityPerformance>
            {
                new ActivityPerformance
                {
                    WhenPerformed = new DateTime(2016, 6, 7)
                },
                new ActivityPerformance
                {
                    WhenPerformed = new DateTime(2016, 6, 8)
                }
            };

            DateTime fakeToday = new DateTime(2016, 6, 7);

            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Sunday], ActivityState.NotScheduled);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Monday], ActivityState.NotScheduled);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Tuesday], ActivityState.Completed);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Wednesday], ActivityState.Completed);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Thursday], ActivityState.NotScheduled);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Friday], ActivityState.Upcoming);
            Assert.Equal(testActivity.PerformanceStatus(fakeToday)[DayOfWeek.Saturday], ActivityState.NotScheduled);
        }
Пример #2
0
        public void TestDaysPerformedProperty()
        {
            Activity testActivity = new Activity();
            testActivity.DaysPerformedList = new List<DayOfWeek>
            {
                DayOfWeek.Friday,
                DayOfWeek.Thursday,
                DayOfWeek.Wednesday
            };

            Assert.Equal(testActivity.DaysPerformed, "Friday,Thursday,Wednesday");
        }
Пример #3
0
 public void TestDaysPerformedEntity()
 {
     Activity testActivity = new Activity("Friday,Thursday,Wednesday");
     Assert.Equal(testActivity.DaysPerformedList, new [] {DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday});
 }
Пример #4
0
        public IActionResult Create(Activity activity)
        {
            if (!ModelState.IsValid)
            {
                return View(activity);
            }

            activity.AssociatedResidence =_context.Residences.First(d => d.ResidenceID == Int32.Parse(Request.Form["AssociatedResidence"].First()));
            _context.Activities.Add(activity);
            _context.SaveChanges();

            return RedirectToAction("View", "Residence", new { id = activity.AssociatedResidence.ResidenceID });
        }