Exemplo n.º 1
0
        public void TestDeletePropertyWithStartAndStop()
        {
            var          start          = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var          stop           = start.AddDays(1.0);
            const string expectedId     = "id";
            const bool   expectedDelete = true;

            using (Packet)
            {
                Packet.WriteId(expectedId);

                using (var orientation = Packet.OpenOrientationProperty())
                    using (var interval = orientation.OpenInterval(start, stop))
                    {
                        interval.WriteDelete(expectedDelete);
                    }
            }

            AssertExpectedJson(new Dictionary <string, object>
            {
                { PacketCesiumWriter.IdPropertyName, expectedId },
                {
                    PacketCesiumWriter.OrientationPropertyName, new Dictionary <string, object>
                    {
                        { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                        { OrientationCesiumWriter.DeletePropertyName, expectedDelete },
                    }
                },
            });
        }
Exemplo n.º 2
0
        public void TestParseIso8601DayOfYear()
        {
            GregorianDate iso    = new GregorianDate(1985, 2, 11, 2, 0, 5.2134);
            GregorianDate result = GregorianDate.Parse("1985-042T02:00:05.2134");

            Assert.AreEqual(iso, result);
            iso    = new GregorianDate(1985, 2, 11, 2, 0, 5.21345);
            result = GregorianDate.Parse("1985-042T02:00:05.21345Z");
            Assert.AreEqual(iso, result);
            iso    = new GregorianDate(1985, 2, 11, 2, 0, 5);
            result = GregorianDate.Parse("1985-042T02:00:05");
            Assert.AreEqual(iso, result);
            iso    = new GregorianDate(1985, 2, 11);
            result = GregorianDate.Parse("1985-042");
            Assert.AreEqual(iso, result);

            // Make sure to check each month to ensure we have it right
            const string first    = "1986-";
            const string last     = "T02:01:04Z";
            JulianDate   baseDate = new GregorianDate(1986, 1, 12, 02, 01, 4).ToJulianDate();

            for (int i = 1; i < 12; i++)
            {
                string        testString = string.Format(first + "{0:000}" + last, 12 + i * 30);
                GregorianDate expected   = baseDate.AddDays(i * 30).ToGregorianDate();
                Assert.AreEqual(expected, GregorianDate.Parse(testString));
            }
        }
Exemplo n.º 3
0
        public void TestDeletePropertyWithStartAndStop()
        {
            var          start                = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var          stop                 = start.AddDays(1.0);
            const string expectedId           = "id";
            const string expectedPropertyName = "foo";
            const bool   expectedDelete       = true;

            using (Packet)
            {
                Packet.WriteId(expectedId);

                using (var writer = new BooleanCesiumWriter(expectedPropertyName))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(start, stop);
                    writer.WriteDelete(expectedDelete);
                }
            }

            AssertExpectedJson(new Dictionary <string, object>
            {
                { PacketCesiumWriter.IdPropertyName, expectedId },
                {
                    expectedPropertyName, new Dictionary <string, object>
                    {
                        { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                        { BooleanCesiumWriter.DeletePropertyName, expectedDelete },
                    }
                },
            });
        }
Exemplo n.º 4
0
        public void TestAvailabilityProperty()
        {
            JulianDate start = new GregorianDate(2012, 4, 2, 1, 2, 3).ToJulianDate();
            JulianDate stop  = new GregorianDate(2012, 4, 3, 1, 2, 3).ToJulianDate();

            m_outputStream.WriteStartSequence();
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                packet.WriteAvailability(start, stop);
            }

            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                packet.WriteAvailability(new TimeInterval(start, stop));
            }

            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                var intervals = new List <TimeInterval>
                {
                    new TimeInterval(start, stop),
                    new TimeInterval(start.AddDays(2.0), stop.AddDays(2.0))
                };
                packet.WriteAvailability(intervals);
            }

            m_outputStream.WriteEndSequence();

            const string expected =
                "[" +
                "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                "{\"availability\":[\"20120402T010203Z/20120403T010203Z\",\"20120404T010203Z/20120405T010203Z\"]}" +
                "]";

            Assert.AreEqual(expected, m_stringWriter.ToString());
        }