public void ShouldNotBeEqualToNull()
        {
            var dateTime = new CypherDateTimeWithZoneId(1947, 12, 17, 15, 12, 01, 789000000, "Europe/Rome");
            var other    = (object)null;

            dateTime.Equals(other).Should().BeFalse();
        }
        public void ShouldNotBeEqualToAnotherType()
        {
            var dateTime = new CypherDateTimeWithZoneId(1947, 12, 17, 15, 12, 01, 789000000, "Europe/Rome");
            var other    = "some string";

            dateTime.Equals(other).Should().BeFalse();
        }
        public void ShouldGenerateDifferentHashcode()
        {
            var dateTime1 = new CypherDateTimeWithZoneId(1947, 12, 17, 15, 12, 01, 789000000, "Europe/Rome");
            var dateTime2 = new CypherDateTimeWithZoneId(new DateTime(1947, 12, 17, 15, 12, 01, 790), "Europe/Rome");
            var dateTime3 = new CypherDateTimeWithZoneId(-695555279, 789000200, "Europe/Rome");

            dateTime1.GetHashCode().Should().NotBe(dateTime2.GetHashCode()).And.NotBe(dateTime3.GetHashCode());
        }
        public void ShouldGenerateSameHashcode()
        {
            var dateTime1 = new CypherDateTimeWithZoneId(1947, 12, 17, 15, 12, 01, 789000000, "Europe/Rome");
            var dateTime2 = new CypherDateTimeWithZoneId(new DateTime(1947, 12, 17, 15, 12, 01, 789), "Europe/Rome");
            var dateTime3 = new CypherDateTimeWithZoneId(-695551679, 789000000, "Europe/Rome");

            dateTime1.GetHashCode().Should().Be(dateTime2.GetHashCode()).And.Be(dateTime3.GetHashCode());
        }
        public void ShouldCreateDateTimeWithZoneIdWithDateTimeComponentsWithNanoseconds()
        {
            var cypherDateTime = new CypherDateTimeWithZoneId(1947, 12, 17, 23, 49, 54, 192794500, "Europe/Rome");

            cypherDateTime.DateTime.Should().Be(new DateTime(1947, 12, 17, 23, 49, 54).AddTicks(1927945));
            cypherDateTime.Offset.Should().Be(TimeSpan.FromHours(1));
            cypherDateTime.ZoneId.Should().Be("Europe/Rome");
        }
        public void ShouldGenerateCorrectString()
        {
            var cypherDateTime    = new CypherDateTimeWithZoneId(1947, 12, 17, 23, 49, 54, 192794500, "Europe/Rome");
            var cypherDateTimeStr = cypherDateTime.ToString();

            cypherDateTimeStr.Should()
            .Be(
                $"DateTimeWithZoneId{{epochSeconds: {cypherDateTime.EpochSeconds}, nanosOfSecond: {cypherDateTime.NanosOfSecond}, zoneId: '{cypherDateTime.ZoneId}'}}");
        }
        public void ShouldCreateDateTimeWithZoneIdWithDateTime()
        {
            var dateTime       = new DateTime(1947, 12, 17, 23, 49, 54, 120);
            var cypherDateTime = new CypherDateTimeWithZoneId(dateTime, "Europe/Rome");

            cypherDateTime.DateTime.Should().Be(dateTime);
            cypherDateTime.Offset.Should().Be(TimeSpan.FromHours(1));
            cypherDateTime.ZoneId.Should().Be("Europe/Rome");
        }
        public void ShouldNotBeEqual()
        {
            var dateTime1 = new CypherDateTimeWithZoneId(1947, 12, 17, 15, 12, 01, 789000000, "Europe/Rome");
            var dateTime2 = new CypherDateTimeWithZoneId(new DateTime(1947, 12, 17, 15, 12, 01, 790), "Europe/Rome");
            var dateTime3 = new CypherDateTimeWithZoneId(-695555279, 789005000, "Europe/Rome");

            dateTime1.Should().NotBe(dateTime2);
            dateTime1.Should().NotBe(dateTime3);
        }
        public void ShouldCreateDateWithRawValues()
        {
            var dateTime       = new DateTime(1947, 12, 17, 23, 49, 54).AddTicks(1927945);
            var cypherDateTime = new CypherDateTimeWithZoneId(TemporalHelpers.SecondsSinceEpoch(dateTime.Ticks),
                                                              TemporalHelpers.NanosOfSecond(dateTime.Ticks), "Europe/Rome");

            cypherDateTime.DateTime.Should().Be(dateTime);
            cypherDateTime.Offset.Should().Be(TimeSpan.FromHours(1));
            cypherDateTime.ZoneId.Should().Be("Europe/Rome");
        }
Exemple #10
0
        public void ShouldWriteDateTimeWithZoneId()
        {
            var dateTime      = new CypherDateTimeWithZoneId(1978, 12, 16, 12, 35, 59, 128000987, "Europe/Istanbul");
            var writerMachine = CreateWriterMachine();
            var writer        = writerMachine.Writer();

            writer.Write(dateTime);

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

            reader.PeekNextType().Should().Be(PackStream.PackType.Struct);
            reader.ReadStructHeader().Should().Be(3);
            reader.ReadStructSignature().Should().Be((byte)'f');
            reader.Read().Should().Be(dateTime.EpochSeconds);
            reader.Read().Should().Be((long)dateTime.NanosOfSecond);
            reader.Read().Should().Be("Europe/Istanbul");
        }
Exemple #11
0
        public void ShouldSendAndReceiveDateTimeWithZoneId()
        {
            var data = new CypherDateTimeWithZoneId(1959, 5, 31, 23, 49, 59, 999999999, "US/Pacific");

            TestSendAndReceiveData(
                "CYPHER runtime=interpreted WITH $x AS x RETURN x, x.year, x.month, x.day, x.hour, x.minute, x.second, x.millisecond, x.microsecond, x.nanosecond, x.timezone",
                data,
                new object[]
            {
                data,
                1959L,
                5L,
                31L,
                23L,
                49L,
                59L,
                999L,
                999999L,
                999999999L,
                "US/Pacific"
            });
        }