Exemplo n.º 1
0
 /// <summary>
 /// Constructs a CurrentChallenge with its fields.
 /// </summary>
 /// <param name="challenge">Which challenge to take on. Null is not allowed as challenge.</param>
 public CurrentChallenge(Challenge challenge)
 {
     if (challenge == null)
     {
         throw new ArgumentException("Null Object is not allowed as challenge for current challenge.");
     }
     Challenge = challenge;
     DateTime now = DateTime.Now;
     StartTime = new Time(now.Hour, now.Minute, now.Second);
 }
Exemplo n.º 2
0
        public void TestChallangeConstructorWithInvalidParameters()
        {
            string name = "John Doe";
            string description = "Complete me";
            Time startTime = new Time(00, 20, 30);
            Time endTime = new Time(01, 30, 20);
            List<Activity> requirements = new List<Activity>();

            Challenge challange = new Challenge(name, description, startTime, endTime, requirements);
        }
Exemplo n.º 3
0
        public void TestTimeConstructor()
        {
            int hour = 2;
            int min = 2;
            int sec = 2;

            Time testTime = new Time(hour, min, sec);

            Assert.AreEqual(hour, testTime.Hours);
            Assert.AreEqual(min, testTime.Minutes);
            Assert.AreEqual(sec, testTime.Seconds);
        }
Exemplo n.º 4
0
        public void TestChallangeConstructorWithValidParameters()
        {
            string name = "John Doe";
            string description = "Complete me";
            Time startTime = new Time(00, 20, 30);
            Time endTime = new Time(01, 30, 20);
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));

            Challenge challange = new Challenge(name, description, startTime, endTime, requirements);

            Assert.AreEqual(name, challange.Name);
            Assert.AreEqual(description, challange.Description);
            Assert.AreEqual(startTime, challange.StartTime);
            Assert.AreEqual(endTime, challange.EndTime);
            Assert.AreEqual(requirements, challange.Requirements);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructs a Challenge with its fields.
        /// </summary>
        /// <param name="name">Name of the challenge.</param>
        /// <param name="description">Description of the challenge.</param>
        /// <param name="startTime">At what time it starts, expressed as 00:00:00.</param>
        /// <param name="endTime">At what time it ends, expressed as 00:00:00.</param>
        /// <param name="requirements"></param>
        public Challenge(string name, string description, Time startTime, Time endTime, List<Activity> requirements)
        {
            Name = name;
            Description = description;
            StartTime = startTime;
            EndTime = endTime;
            Requirements = requirements;

            if (Requirements == null)
            {
                throw new ArgumentException("Null List is not allowed as requirements for a challenge.");
            }

            if (Requirements.Count == 0)
            {
                throw new ArgumentException("No requirements specified for a challenge.");
            }
        }
Exemplo n.º 6
0
        public void TestIsOverEvaluatesToTrue()
        {
            string name = "John Doe";
            string description = "Complete me";
            Time startTime = new Time(00, 00, 00);
            Time endTime = new Time(00, 00, 01);
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));

            Challenge challenge = new Challenge(name, description, startTime, endTime, requirements);
            bool expectedToBeTrue = true;

            Assert.AreEqual(expectedToBeTrue, challenge.IsOver());
        }