예제 #1
0
 private void ValidateNullWorkingCalendar(IProjectCalendar calendar)
 {
     if (calendar == null)
     {
         throw new InvalidActivityCalendarException();
     }
 }
예제 #2
0
        public void AProjectWithoutWorkingCalendarIsCreatedWithDefaultWorkingCalendar()
        {
            DateTime monday    = new DateTime(2013, 7, 1);
            DateTime tuesday   = new DateTime(2013, 7, 2);
            DateTime wednesday = new DateTime(2013, 7, 3);
            DateTime thursday  = new DateTime(2013, 7, 4);
            DateTime friday    = new DateTime(2013, 7, 5);
            DateTime saturday  = new DateTime(2013, 7, 6);
            DateTime sunday    = new DateTime(2013, 7, 7);

            ProjectFactory projectFactory = new ProjectFactory(calendarFactory);
            Project        project        = projectFactory.CreateProject(VALID_PROJECT_NAME);

            IProjectCalendar calendar = project.Calendar;

            Assert.That(calendar.IsWorkingDay(monday), Is.True);
            Assert.That(calendar.IsWorkingDay(tuesday), Is.True);
            Assert.That(calendar.IsWorkingDay(wednesday), Is.True);
            Assert.That(calendar.IsWorkingDay(thursday), Is.True);
            Assert.That(calendar.IsWorkingDay(friday), Is.True);
            Assert.That(calendar.IsWorkingDay(saturday), Is.False);
            Assert.That(calendar.IsWorkingDay(sunday), Is.False);

            Assert.That(calendar.GetWorkingHours(monday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(tuesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(wednesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(thursday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(friday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(saturday), Is.EqualTo(0));
            Assert.That(calendar.GetWorkingHours(sunday), Is.EqualTo(0));
        }
예제 #3
0
        protected Activity(IProjectCalendar calendar, String name)
        {
            ValidateNullWorkingCalendar(calendar);
            ValidateNullOrEmptyProjectName(name);

            this.calendar = calendar;
            this.name     = name;
        }
예제 #4
0
        public void CannotCreateAProjectWithEmptyName()
        {
            ProjectFactory         projectFactory         = new ProjectFactory(calendarFactory);
            ProjectCalendarFactory workingCalendarFactory = new ProjectCalendarFactory();
            IProjectCalendar       calendar = workingCalendarFactory.CreateDefaultWorkingCalendar();

            Exception caughtException = Assert.Catch(() => projectFactory.CreateProject(calendar, ""));

            Assert.That(caughtException, Is.InstanceOf <InvalidActivityNameException>());
        }
예제 #5
0
        public void IfADateIsNoHolidayItCannotRetrieveIt()
        {
            ProjectCalendarFactory calendarFactory = new ProjectCalendarFactory();

            IProjectCalendar calendar = calendarFactory.CreateDefaultWorkingCalendar();

            bool isHoliday = calendar.IsHoliday(wednesday);

            Assert.That(isHoliday, Is.False);
        }
예제 #6
0
        public void IfADateIsHolidayWotkingHoursAre0()
        {
            ProjectCalendarFactory calendarFactory = new ProjectCalendarFactory();

            IProjectCalendar calendar = calendarFactory.CreateDefaultWorkingCalendar();

            calendar.AddHoliday(wednesday);

            int workingHours = calendar.GetWorkingHours(wednesday);

            Assert.That(workingHours, Is.EqualTo(0));
        }
예제 #7
0
        public void ItCanAddAHolidayAndThenRetrieveIt()
        {
            ProjectCalendarFactory calendarFactory = new ProjectCalendarFactory();

            IProjectCalendar calendar = calendarFactory.CreateDefaultWorkingCalendar();

            calendar.AddHoliday(wednesday);

            bool isHoliday = calendar.IsHoliday(wednesday);

            Assert.That(isHoliday, Is.True);
        }
예제 #8
0
        public void DefaultWorkingCalendarHas8WorkingHoursFromMondayToFriday()
        {
            ProjectCalendarFactory calendarFactory = new ProjectCalendarFactory();

            IProjectCalendar calendar = calendarFactory.CreateDefaultWorkingCalendar();

            Assert.That(calendar.GetWorkingHours(monday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(tuesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(wednesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(thursday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(friday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(saturday), Is.EqualTo(0));
            Assert.That(calendar.GetWorkingHours(sunday), Is.EqualTo(0));
        }
예제 #9
0
        public void DefaultWorkingCalendarHasMondayToFridayWorkingDays()
        {
            ProjectCalendarFactory calendarFactory = new ProjectCalendarFactory();

            IProjectCalendar calendar = calendarFactory.CreateDefaultWorkingCalendar();

            Assert.That(calendar.IsWorkingDay(monday), Is.True);
            Assert.That(calendar.IsWorkingDay(tuesday), Is.True);
            Assert.That(calendar.IsWorkingDay(wednesday), Is.True);
            Assert.That(calendar.IsWorkingDay(thursday), Is.True);
            Assert.That(calendar.IsWorkingDay(friday), Is.True);
            Assert.That(calendar.IsWorkingDay(saturday), Is.False);
            Assert.That(calendar.IsWorkingDay(sunday), Is.False);
        }
예제 #10
0
        public void AProjectWithoutWorkingCalendarIsCreatedWithDefaultWorkingCalendar()
        {
            DateTime monday    = new DateTime(2013, 7, 1);
            DateTime tuesday   = new DateTime(2013, 7, 2);
            DateTime wednesday = new DateTime(2013, 7, 3);
            DateTime thursday  = new DateTime(2013, 7, 4);
            DateTime friday    = new DateTime(2013, 7, 5);
            DateTime saturday  = new DateTime(2013, 7, 6);
            DateTime sunday    = new DateTime(2013, 7, 7);

            Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>();

            calendarMock.Setup(x => x.GetWorkingHours(It.IsAny <DateTime>())).Returns(8);
            calendarMock.Setup(x => x.GetWorkingHours(saturday)).Returns(0);
            calendarMock.Setup(x => x.GetWorkingHours(sunday)).Returns(0);
            calendarMock.Setup(x => x.IsWorkingDay(It.IsAny <DateTime>())).Returns(true);
            calendarMock.Setup(x => x.IsWorkingDay(saturday)).Returns(false);
            calendarMock.Setup(x => x.IsWorkingDay(sunday)).Returns(false);

            Project project = new Project(calendarMock.Object, VALID_PROJECT_NAME);

            IProjectCalendar calendar = project.Calendar;

            Assert.That(calendar.IsWorkingDay(monday), Is.True);
            Assert.That(calendar.IsWorkingDay(tuesday), Is.True);
            Assert.That(calendar.IsWorkingDay(wednesday), Is.True);
            Assert.That(calendar.IsWorkingDay(thursday), Is.True);
            Assert.That(calendar.IsWorkingDay(friday), Is.True);
            Assert.That(calendar.IsWorkingDay(saturday), Is.False);
            Assert.That(calendar.IsWorkingDay(sunday), Is.False);

            Assert.That(calendar.GetWorkingHours(monday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(tuesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(wednesday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(thursday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(friday), Is.EqualTo(8));
            Assert.That(calendar.GetWorkingHours(saturday), Is.EqualTo(0));
            Assert.That(calendar.GetWorkingHours(sunday), Is.EqualTo(0));
        }
예제 #11
0
 public Project(IProjectCalendar calendar, string name)
     : base(null, calendar, name)
 {
     InitializeMembers();
 }
예제 #12
0
 public Project CreateProject(IProjectCalendar calendar, string name)
 {
     return(new Project(calendar, name));
 }
예제 #13
0
 public ProjectTask(ProjectTask parent, IProjectCalendar calendar, string name)
     : base(calendar, name)
 {
     this.parent = parent;
     InitializeTasks();
 }
예제 #14
0
        private Project CreateProjectWithDefaultNameAndDefaultCalendar(IProjectCalendar calendar)
        {
            ProjectFactory projectFactory = new ProjectFactory(calendarFactory);

            return(projectFactory.CreateProject(calendar, VALID_PROJECT_NAME));
        }