Example #1
0
        public void SetFrequencyAndStartClock()
        {
            m_Clock.Add(m_Tickable);

            m_Clock.SetFrequency(new TimeSpan(0));
            m_Clock.Start();
            m_Clock.Oscillate();

            m_Tickable.Ticks
            .Should().Be(1);
        }
Example #2
0
    public void Clocks_are_immutable()
    {
        var sut      = new Clock(0, 0);
        var sutPlus1 = sut.Add(1);

        Assert.NotEqual(sutPlus1, sut);
    }
Example #3
0
 public void Tick(string name)
 {
     //if new name
     if (!Clock.Keys.Contains(name))
     {
         Clock.Add(name, 0);
     }
     Clock[name]++;
 }
Example #4
0
    public void Clocks_are_immutable()
    {
        var sut = new Clock(0, 0);

        System.Console.WriteLine(sut);

        var sutPlus1 = sut.Add(1);

        System.Console.WriteLine(sutPlus1);
        System.Console.WriteLine(sut);

        Assert.NotEqual(sutPlus1, sut);
    }
Example #5
0
 public void Merge(VectorClock other)
 {
     foreach (var el in other.Clock.ToList())
     {
         if (Clock.ContainsKey(el.Key))
         {
             Clock[el.Key] = Math.Max(el.Value, Clock[el.Key]);
         }
         else
         {
             Clock.Add(el.Key, el.Value);
         }
     }
 }
Example #6
0
    public void EqualityOperators_ShouldWorkTheSameAsEquals(int hours, int minutes, int minutesToAdd)
    {
        var sut         = new Clock(hours, minutes);
        var sutEqual    = new Clock(hours, minutes);
        var sutNotEqual = sutEqual.Add(minutesToAdd);

        Assert.Equal(sut, sutEqual);
        Assert.True(sut == sutEqual);
        Assert.False(sut != sutEqual);

        Assert.NotEqual(sut, sutNotEqual);
        Assert.False(sut == sutNotEqual);
        Assert.True(sut != sutNotEqual);
    }
Example #7
0
    public void Add_no_minutes()
    {
        var sut = new Clock(6, 41);

        Assert.Equal("06:41", sut.Add(0).ToString());
    }
Example #8
0
    public void Add_to_next_hour()
    {
        var sut = new Clock(0, 45);

        Assert.Equal("01:25", sut.Add(40).ToString());
    }
Example #9
0
        public void Add_more_than_two_days()
        {
            var clock = new Clock(1, 1);

            Assert.AreEqual("11:21", clock.Add(3500).ToString());
        }
Example #10
0
    public void Add_minutes()
    {
        var sut = new Clock(10, 0);

        Assert.Equal("10:03", sut.Add(3).ToString());
    }
Example #11
0
    public void Add_more_than_two_days()
    {
        var sut = new Clock(1, 1);

        Assert.Equal("11:21", sut.Add(3500).ToString());
    }
Example #12
0
    public void Subtract_more_than_an_hour()
    {
        var sut = new Clock(10, 3);

        Assert.Equal("08:53", sut.Add(-70).ToString());
    }
Example #13
0
    public void Subtract_minutes()
    {
        var sut = new Clock(10, 3);

        Assert.Equal("10:00", sut.Add(-3).ToString());
    }
Example #14
0
    public void Add_across_midnight()
    {
        var sut = new Clock(23, 59);

        Assert.Equal("00:01", sut.Add(2).ToString());
    }
Example #15
0
    public void Subtract_more_than_two_days()
    {
        var sut = new Clock(2, 20);

        Assert.Equal("00:20", sut.Add(-3000).ToString());
    }
Example #16
0
        public void Add_minutes()
        {
            var clock = new Clock(10, 0);

            Assert.AreEqual("10:03", clock.Add(3).ToString());
        }
Example #17
0
    public void Subtract_more_than_two_hours_with_borrow()
    {
        var sut = new Clock(6, 15);

        Assert.Equal("03:35", sut.Add(-160).ToString());
    }
Example #18
0
    public void Subtract_more_than_two_hours()
    {
        var sut = new Clock(0, 0);

        Assert.Equal("21:20", sut.Add(-160).ToString());
    }
Example #19
0
    public void Subtract_across_midnight()
    {
        var sut = new Clock(0, 3);

        Assert.Equal("23:59", sut.Add(-4).ToString());
    }
Example #20
0
    public void Add_more_than_one_hour()
    {
        var sut = new Clock(10, 0);

        Assert.Equal("11:01", sut.Add(61).ToString());
    }
Example #21
0
        public void Add_to_next_hour()
        {
            var clock = new Clock(0, 45);

            Assert.AreEqual("01:25", clock.Add(40).ToString());
        }
Example #22
0
    public void Add_more_than_two_hours_with_carry()
    {
        var sut = new Clock(0, 45);

        Assert.Equal("03:25", sut.Add(160).ToString());
    }
Example #23
0
        public void Add_more_than_one_hour()
        {
            var clock = new Clock(10, 0);

            Assert.AreEqual("11:01", clock.Add(61).ToString());
        }
Example #24
0
    public void Add_more_than_one_day_1500_min_25_hrs_()
    {
        var sut = new Clock(5, 32);

        Assert.Equal("06:32", sut.Add(1500).ToString());
    }
Example #25
0
        public void Add_across_midnight()
        {
            var clock = new Clock(23, 59);

            Assert.AreEqual("00:01", clock.Add(2).ToString());
        }
Example #26
0
        public void Add_no_minutes()
        {
            var clock = new Clock(6, 41);

            Assert.AreEqual("06:41", clock.Add(0).ToString());
        }
Example #27
0
    public void Subtract_to_previous_hour()
    {
        var sut = new Clock(10, 3);

        Assert.Equal("09:33", sut.Add(-30).ToString());
    }