Exemplo n.º 1
0
        public void WriteTests_SameVersion_MultipleRows()
        {
            var person1 = new V1.Person {
                Name = "Kawhi"
            };
            var person2 = new V1.Person {
                Name = "Kyle"
            };

            var buffer = new byte[person1.BufferSize + person2.BufferSize];
            var ms     = new MemoryStream(buffer);

            person1.Serialize(ms);
            person2.Serialize(ms);
            Assert.Equal(ms.Length, buffer.Length);

            var span = buffer.AsSpan();

            var row1 = new V1.PersonMirror(span);

            Assert.Equal(person1.Name, row1.Name);

            var row2 = new V1.PersonMirror(span.Slice(person1.BufferSize));

            Assert.Equal(person2.Name, row2.Name);
        }
Exemplo n.º 2
0
        public void WriteTests_DifferentVersions_MultipleRows()
        {
            var person1 = new V1.Person {
                Name = "Kawhi"
            };
            var person2 = new V2.Person {
                FirstName = "Kyle", LastName = "Lowry"
            };

            var buffer = new byte[person1.BufferSize + person2.BufferSize];
            var ms     = new MemoryStream(buffer);

            person1.Serialize(ms);
            person2.Serialize(ms);
            Assert.Equal(ms.Length, buffer.Length);

            var span = buffer.AsSpan();

            var row11 = new V1.PersonMirror(span);

            Assert.Equal(person1.Name, row11.Name);

            var row12 = new V2.PersonMirror(span);

            Assert.Equal(person1.Name, row12.FirstName);

            var row21 = new V1.PersonMirror(span.Slice(person1.BufferSize));

            Assert.Equal(person2.FirstName, row21.Name);

            var row22 = new V2.PersonMirror(span.Slice(person1.BufferSize));

            Assert.Equal(person2.FirstName, row22.FirstName);
            Assert.Equal(person2.LastName, row22.LastName);
        }
Exemplo n.º 3
0
        public void WriteTests_Simple()
        {
            using (var fixture = new TemporaryFileFixture())
            {
                var person = new V1.Person {
                    Name = "Kawhi"
                };

                person.Serialize(fixture.FileStream);
            }
        }
Exemplo n.º 4
0
        public void ReadTests_NextVersion()
        {
            var person = new V1.Person {
                Name = "Kawhi"
            };

            var buffer = new byte[person.BufferSize];
            var ms     = new MemoryStream(buffer);

            person.Serialize(ms);
            Assert.Equal(ms.Length, buffer.Length);

            var span   = buffer.AsSpan();
            var mirror = new V2.PersonMirror(span);

            Assert.Equal(person.Name, mirror.FirstName);
        }