Ejemplo n.º 1
0
        public void LengthAddsUpLengthOfAllTheIntervals()
        {
            var intervals = new List<Interval>();
            intervals.Add(new TestInterval(new DateTime(), new TimeSpan(0, 0, 1), null));
            intervals.Add(new TestInterval(new DateTime(), new TimeSpan(0, 0, 1), null));

            var session = new TestSession(null, null, intervals);

            Assert.That(session.Length.TotalSeconds, Is.EqualTo(2));
        }
        public void SessionWith1IntervalResultsIn1ProgrammerWith100Percent()
        {
            var programmerJoe = new Programmer("Joe");
            var intervals = new List<Interval>();
            intervals.Add(new TestInterval(new DateTime(2000, 1, 1, 0, 0, 0), new TimeSpan(0, 0, 10), programmerJoe));
            var session = new TestSession(programmerJoe, new Programmer("Bob"), intervals);

            var statGenerator = new SessionPercentageStatisticGenerator();
            var results = statGenerator.Generate(session);

            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[programmerJoe].Percentage, Is.EqualTo(100));
        }
        public void SessionWith2IntervalsOfOddLengthsResultsInTotalOf100Percent()
        {
            var programmerJoe = new Programmer("Joe");
            var programmerBob = new Programmer("Bob");
            var intervals = new List<Interval>();
            intervals.Add(new TestInterval(new DateTime(2000, 1, 1, 0, 0, 0), new TimeSpan(0, 0, 1), programmerJoe));
            intervals.Add(new TestInterval(new DateTime(2000, 1, 1, 0, 0, 1), new TimeSpan(0, 0, 7), programmerBob));
            var session = new TestSession(programmerJoe, programmerBob, intervals);

            var statGenerator = new SessionPercentageStatisticGenerator();
            var results = statGenerator.Generate(session);

            Assert.That(results.Count, Is.EqualTo(2));
            Assert.That(results[programmerJoe].Percentage, Is.EqualTo(12));
            Assert.That(results[programmerBob].Percentage, Is.EqualTo(88));
        }
        public void SessionWith2EqualIntervalsResultsIn2ProgrammersWith50PercentEach()
        {
            var programmerJoe = new Programmer("Joe");
            var programmerBob = new Programmer("Bob");
            var intervals = new List<Interval>();
            intervals.Add(new TestInterval(new DateTime(2000, 1, 1, 0, 0, 0), new TimeSpan(0, 0, 5), programmerJoe));
            intervals.Add(new TestInterval(new DateTime(2000, 1, 1, 0, 0, 5), new TimeSpan(0, 0, 5), programmerBob));
            var session = new TestSession(programmerJoe, programmerBob, intervals);

            var statGenerator = new SessionPercentageStatisticGenerator();
            var results = statGenerator.Generate(session);

            Assert.That(results.Count, Is.EqualTo(2));
            Assert.That(results[programmerJoe].Percentage, Is.EqualTo(50));
            Assert.That(results[programmerBob].Percentage, Is.EqualTo(50));
        }