Exemple #1
0
        public void CanReadWriteMultiple()
        {
            var sut1 = _fixture.Create <DbaseNullableBoolean>();
            var sut2 = _fixture.Create <DbaseNullableBoolean>();

            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 DbaseNullableBoolean(sut1.Field);
                    var result2 = new DbaseNullableBoolean(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);
                }
            }
        }
Exemple #2
0
        public void CanNotReadPastEndOfStream()
        {
            var sut = _fixture.Create <DbaseNullableBoolean>();

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

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

            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 DbaseNullableBoolean(sut.Field);
                    result.Read(reader);

                    Assert.Equal(sut.Field, result.Field);
                    Assert.Equal(value, result.Value);
                }
            }
        }
 public void Visit(DbaseNullableBoolean value)
 {
     value.Value = _fixture.Create <bool?>();
 }
Exemple #5
0
 public void Visit(DbaseNullableBoolean value)
 {
     HashCode = value.Value?.GetHashCode() ?? 0;
 }
Exemple #6
0
 public void Visit(DbaseNullableBoolean value)
 {
     Comparer = new DelegatingDbaseFieldValueEqualityComparer <DbaseNullableBoolean>(
         new DbaseNullableBooleanEqualityComparer());
 }