コード例 #1
0
        [DataRow(5, 5, 0, false, 0, 0, true, 4)]     //will not advance as start date is in the future
        public void AdvanceJob_ShouldNotAdvance(int startdate, int duration, int CurrentDay, bool IsComplete, int progress, int dayssincecreation, bool iscurrentlyprogressing, int daysToAdvance)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = iscurrentlyprogressing,
                Days_Since_Creation    = dayssincecreation,
                Complete = IsComplete
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.AdvanceJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, IsComplete, "ISComplete improperly changed");
            Assert.AreEqual(J_Test.StartDate, startdate, "StartDate improperly changed");
            Assert.AreEqual(J_Test.Duration, duration, "Duration improperly changed");
            Assert.AreEqual(J_Test.Progress, progress, "Progress improperly changed");
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, iscurrentlyprogressing, "IsCurrentlyProgressing improperly changed");
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation + daysToAdvance, "Days_Since_Creation improperly advanced");
        }
コード例 #2
0
        public void AdvanceJob_NegativeAdvanceThrowsException()
        {
            //arrange
            Job J_Test = new Job(0)
            {
                StartDate = 0,
                Duration  = 0,
                Progress  = 0,
                IsCurrentlyProgressing = false,
                Days_Since_Creation    = 0,
                Complete  = false,
                Recurring = false
            };
            int daysToAdvance = -1;

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);


            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act // assert
            Assert.ThrowsException <InvalidOperationException>(() => JL_Test.AdvanceJob(J_Test, daysToAdvance));
        }
コード例 #3
0
        public void AdvanceJob_ShouldAdvance(int startdate, int duration, int CurrentDay, int progress, int dayssincecreation, int daysToAdvance)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = true,
                Days_Since_Creation    = dayssincecreation,
                Complete      = false,
                SuccessChance = 0,
                FailureChance = 0
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.AdvanceJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, false, "Complete not false");
            Assert.AreEqual(J_Test.StartDate, startdate, "StartDate improperly changed");
            Assert.AreEqual(J_Test.Duration, duration, "Duration improperly changed");
            Assert.AreEqual(J_Test.Progress, progress + daysToAdvance, "Progress improperly advanced");
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, true, "IsCurrentlyProgressing not true");
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation + daysToAdvance, "Days_Since_Creation improperly advanced");

            EAM.Verify(x => x.GetEvent <RequestJobEventEvent>(), Times.Exactly(0));
        }
コード例 #4
0
        public void AdvanceJob_RecurringCompleted(int startdate, int duration, int CurrentDay, int progress, int dayssincecreation, int daysToAdvance, int timeswillcomplete)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = true,
                Days_Since_Creation    = dayssincecreation,
                Complete      = false,
                Recurring     = true,
                SuccessChance = 0,
                FailureChance = 0
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.AdvanceJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, false);
            Assert.AreEqual(J_Test.StartDate, startdate);
            Assert.AreEqual(J_Test.Duration, duration);
            Assert.AreEqual(J_Test.Progress, (daysToAdvance - (duration - progress)) % duration);
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, true);
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation + daysToAdvance);

            EAM.Verify(x => x.GetEvent <RequestJobEventEvent>(), Times.Exactly(timeswillcomplete));
        }