public void ShouldSerializeDateTime(
			[Values(1, 10, 100, 10000)]
			int numberOfEntries)
        {
            var randomDateTimes = Helpers.GetRandomDateTimes(numberOfEntries);

            var stream = new MemoryStream();
            using(var writer = new PrimitiveWriter(stream))
            {
                for(var i = 0; i < randomDateTimes.Length; i++)
                {
                    writer.Write(randomDateTimes[i]);
                }
            }
            var position = stream.Position;
            stream.Seek(0, SeekOrigin.Begin);

            using(var reader = new PrimitiveReader(stream))
            {
                for(var i = 0; i < randomDateTimes.Length; i++)
                {
                    Assert.AreEqual(randomDateTimes[i], reader.ReadDateTime());
                }
            }
            Assert.AreEqual(position, stream.Position, StreamCorruptedMessage);
        }
Пример #2
0
        public void ShouldSerializeTimeSpan(
            [Values(1, 10, 100, 10000)]
            int numberOfEntries)
        {
            var randomDateTimes = Helpers.GetRandomDateTimes(numberOfEntries);

            var stream = new MemoryStream();

            using (var writer = new PrimitiveWriter(stream))
            {
                for (var i = 0; i < randomDateTimes.Length; i++)
                {
                    writer.Write(randomDateTimes[i]);
                }
            }
            var position = stream.Position;

            stream.Seek(0, SeekOrigin.Begin);

            using (var reader = new PrimitiveReader(stream))
            {
                for (var i = 0; i < randomDateTimes.Length; i++)
                {
                    Assert.AreEqual(randomDateTimes[i], reader.ReadDateTime());
                }
            }
            Assert.AreEqual(position, stream.Position, StreamCorruptedMessage);
        }
Пример #3
0
        public void TestingDateTime(DateTime init)
        {
            ResetBois();

            PrimitiveWriter.WriteValue(Writer, init);
            ResetStream();

            var final = PrimitiveReader.ReadDateTime(Reader);

            final.Should().Be(init);
        }