Exemplo n.º 1
0
        public void TickScaleTest1to7()
        {
            var scale = Timescale.FromEpoch(1, 1, 1, TimeSpan.TicksPerDay / 7);

            scale.Epoch.Should().Be(0);
            scale.TicksPerDay.Should().Be(TimeSpan.TicksPerDay / 7);
            scale.NetToScale(1234567).Should().Be(1234567 / 7);
            scale.ScaleToNet(1234567).Should().Be(1234567 * 7);
        }
Exemplo n.º 2
0
        public void J2000EpochDay365Resolution()
        {
            Time.Scale = Timescale.FromEpoch(2000, 1, 1, 1);
            Time t = new Time(2001, 1, 1);

            t.Ticks.Should().Be(366);
            t.Year.Should().Be(2001);
            t.Month.Should().Be(1);
            t.Day.Should().Be(1);
        }
        public void TimeScaleCollisionIgnored()
        {
            Time.ScaleCollisionBehavior = ScaleCollisionBehavior.Ignore;
            Time.Scale = Timescale.FromEpoch(2000, 1, 1, 86400);
            var stream = new MemoryStream();

            using (var tf = TeaFile <Event <int> > .Create(stream))
            {
            }
            stream.Position = 0;
            Time.Scale      = Timescale.Net;
            TeaFile.OpenRead(stream);
        }
        public void TimeScaleCollisionThrowsTimescaleException()
        {
            Time.ScaleCollisionBehavior = ScaleCollisionBehavior.ThrowException;
            Time.Scale = Timescale.FromEpoch(2000, 1, 1, 86400);
            var stream = new MemoryStream();

            using (var tf = TeaFile <Event <int> > .Create(stream))
            {
            }
            stream.Position = 0;
            Time.Scale      = Timescale.Net;
            Executing.This(() => TeaFile.OpenRead(stream)).Should().Throw <TimescaleException>();
        }
        public void TimeScaleCollisionUse()
        {
            Time.ScaleCollisionBehavior = ScaleCollisionBehavior.UseNewScale;
            Time.Scale = Timescale.FromEpoch(2000, 1, 1, 86400);
            var stream = new MemoryStream();

            using (TeaFile <Event <int> > .Create(stream))
            {
            }
            stream.Position = 0;
            Time.Scale      = Timescale.Net;
            TeaFile.OpenRead(stream);
            Time.Scale.Should().Be(Timescale.FromEpoch(2000, 1, 1, 86400));
        }
Exemplo n.º 6
0
 public void ToStringTest()
 {
     Timescale.Net.ToString().Should().Be("Net");
     Timescale.Java.ToString().Should().Be("Java");
     Timescale.FromEpoch(1000, 1).ToString().Should().Be("1000,1");
 }
Exemplo n.º 7
0
 public void WellknownNames()
 {
     Timescale.Net.WellKnownName.Should().Be("Net");
     Timescale.Java.WellKnownName.Should().Be("Java");
     Timescale.FromEpoch(222, 33).WellKnownName.Should().Be("Custom");
 }
Exemplo n.º 8
0
 public void ExoticCoverage()
 {
     Timescale.Java.GetHashCode().Should().Not.Be.EqualTo(Timescale.Net.GetHashCode()); // otherwise our Hashcode generation would be questionable
     Executing.This(() => Timescale.FromEpoch(1, TimeSpan.TicksPerDay * 2)).Should().Throw <ArgumentException>();
     Executing.This(() => Timescale.FromEpoch(1, 1, 1, TimeSpan.TicksPerDay * 2)).Should().Throw <ArgumentException>();
 }
 public bool Equals(Timescale scale)
 {
     return(this.Epoch == scale.Epoch &&
            this.TicksPerDay == scale.TicksPerDay);
 }