Ejemplo n.º 1
0
        public void Initialize()
        {
            var origin = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            Assert.That(Clock.Origin, Is.EqualTo(origin));

            var options = new ClockOptions
            {
                OffsetMilliseconds = 1000
            };

            Assert.That(Clock.ToEpoch(origin), Is.EqualTo(0));
            Assert.That(Clock.ToDateTime(0), Is.EqualTo(origin));

            Clock.Reset();

            Clock.Initialize(options);
            Clock.Initialize(options); // ok to re-initialize with same options

            options.OffsetMilliseconds = 2000;
            Assert.Throws <InvalidOperationException>(() => Clock.Initialize(options)); // not ok with different options

            Assert.That(Clock.ToEpoch(origin), Is.EqualTo(1000));
            Assert.That(Clock.ToDateTime(1000), Is.EqualTo(origin));

            Clock.Reset();

            Assert.That(Clock.ToEpoch(origin), Is.EqualTo(0));

            Clock.Initialize(new ClockOptions());

            Clock.Reset();
        }
Ejemplo n.º 2
0
        public void Options()
        {
            var options = new ClockOptions {
                OffsetMilliseconds = 100
            };

            Assert.That(options.OffsetMilliseconds, Is.EqualTo(100));

            var clone = options.Clone();

            Assert.That(clone.OffsetMilliseconds, Is.EqualTo(100));
        }
Ejemplo n.º 3
0
Archivo: Clock.cs Proyecto: linfx/LinFx
 public Clock(IOptions <ClockOptions> options)
 {
     Options = options.Value;
 }