예제 #1
0
        public void CanReadWriteMultiple()
        {
            var sut1 = _fixture.Create <DbaseLogical>();
            var sut2 = _fixture.Create <DbaseLogical>();

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    sut1.Write(writer);
                    sut2.Write(writer);
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result1 = new DbaseLogical(sut1.Field);
                    var result2 = new DbaseLogical(sut2.Field);
                    result1.Read(reader);
                    result2.Read(reader);

                    Assert.Equal(sut1.Field, result1.Field);
                    Assert.Equal(sut2.Field, result2.Field);
                    Assert.Equal(sut1.Value, result1.Value);
                    Assert.Equal(sut2.Value, result2.Value);
                }
            }
        }
예제 #2
0
        public void CanReadWriteNull()
        {
            var sut = _fixture.Create <DbaseLogical>();

            sut.Value = null;

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    sut.Write(writer);
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result = new DbaseLogical(sut.Field);
                    result.Read(reader);

                    Assert.Equal(sut.Field, result.Field);
                    Assert.Equal(sut.Value, result.Value);
                }
            }
        }
예제 #3
0
        public void CanNotReadPastEndOfStream()
        {
            var sut = _fixture.Create <DbaseLogical>();

            using (var stream = new MemoryStream())
            {
                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result = new DbaseLogical(sut.Field);
                    Assert.Throws <EndOfStreamException>(() => result.Read(reader));
                }
            }
        }
예제 #4
0
        public void CanReadAllValidRepresentations(char representation, bool?value)
        {
            var sut = _fixture.Create <DbaseLogical>();

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    writer.Write(Convert.ToByte(representation));
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result = new DbaseLogical(sut.Field);
                    result.Read(reader);

                    Assert.Equal(sut.Field, result.Field);
                    Assert.Equal(value, result.Value);
                }
            }
        }