Exemplo n.º 1
0
        public void ShouldCreateTimeWithOffsetWithTimeComponents()
        {
            var cypherTime = new CypherTimeWithOffset(13, 15, 59, 1500);

            cypherTime.Time.Should().Be(new TimeSpan(13, 15, 59));
            cypherTime.Offset.Should().Be(TimeSpan.FromSeconds(1500));
        }
Exemplo n.º 2
0
        public void ShouldNotBeEqualToNull()
        {
            var time  = new CypherTimeWithOffset(12, 49, 55, 123000000, 1800);
            var other = (object)null;

            time.Equals(other).Should().BeFalse();
        }
Exemplo n.º 3
0
        public void ShouldNotBeEqualToAnotherType()
        {
            var time  = new CypherTimeWithOffset(12, 49, 55, 123000000, 1800);
            var other = "some string";

            time.Equals(other).Should().BeFalse();
        }
Exemplo n.º 4
0
        public void ShouldGenerateCorrectString()
        {
            var cypherTime    = new CypherTimeWithOffset(13, 15, 59, 274000000, 1500);
            var cypherTimeStr = cypherTime.ToString();

            cypherTimeStr.Should()
            .Be($"TimeWithOffset{{nanosOfDay: {cypherTime.NanosecondsOfDay}, offsetSeconds: {cypherTime.OffsetSeconds}}}");
        }
Exemplo n.º 5
0
        public void ShouldCreateTimeWithOffsetWithRawValues()
        {
            var time       = new TimeSpan(0, 13, 59, 59, 25);
            var cypherTime = new CypherTimeWithOffset(time.Ticks * 100, 1500);

            cypherTime.Time.Should().Be(time);
            cypherTime.Offset.Should().Be(TimeSpan.FromSeconds(1500));
        }
Exemplo n.º 6
0
        public void ShouldGenerateDifferentHashcode()
        {
            var time1 = new CypherTimeWithOffset(12, 49, 55, 123000000, 1500);
            var time2 = new CypherTimeWithOffset(new DateTime(2017, 1, 1, 12, 49, 55, 123), TimeSpan.FromSeconds(1800));
            var time3 = new CypherTimeWithOffset(new TimeSpan(0, 12, 49, 55, 125), TimeSpan.FromSeconds(1500));
            var time4 = new CypherTimeWithOffset(46195123003000, 1500);

            time1.GetHashCode().Should().NotBe(time2.GetHashCode()).And.NotBe(time3.GetHashCode()).And
            .NotBe(time4.GetHashCode());
        }
Exemplo n.º 7
0
        public void ShouldBeEqual()
        {
            var time1 = new CypherTimeWithOffset(12, 49, 55, 123000000, 1500);
            var time2 = new CypherTimeWithOffset(new DateTime(2017, 1, 1, 12, 49, 55, 123), TimeSpan.FromSeconds(1500));
            var time3 = new CypherTimeWithOffset(new TimeSpan(0, 12, 49, 55, 123), TimeSpan.FromSeconds(1500));
            var time4 = new CypherTimeWithOffset(46195123000000, 1500);

            time1.Equals(time2).Should().BeTrue();
            time1.Equals(time3).Should().BeTrue();
            time1.Equals(time4).Should().BeTrue();
        }
Exemplo n.º 8
0
        public void ShouldWriteTimeWithOffset()
        {
            var time          = new CypherTimeWithOffset(12, 35, 59, 128000987, (int)TimeSpan.FromMinutes(150).TotalSeconds);
            var writerMachine = CreateWriterMachine();
            var writer        = writerMachine.Writer();

            writer.Write(time);

            var readerMachine = CreateReaderMachine(writerMachine.GetOutput());
            var reader        = readerMachine.Reader();

            reader.PeekNextType().Should().Be(PackStream.PackType.Struct);
            reader.ReadStructHeader().Should().Be(2);
            reader.ReadStructSignature().Should().Be((byte)'T');
            reader.Read().Should().Be(time.NanosecondsOfDay);
            reader.Read().Should().Be((long)time.OffsetSeconds);
        }
Exemplo n.º 9
0
        public void ShouldSendAndReceiveTimeWithOffset()
        {
            var data = new CypherTimeWithOffset(12, 34, 56, 789012587, (int)TimeSpan.FromMinutes(90).TotalSeconds);

            TestSendAndReceiveData(
                "CYPHER runtime=interpreted WITH $x AS x RETURN x, x.hour, x.minute, x.second, x.millisecond, x.microsecond, x.nanosecond, x.offset",
                data,
                new object[]
            {
                data,
                12L,
                34L,
                56L,
                789L,
                789012L,
                789012587L,
                "+01:30"
            });
        }