public void CreateSingleFieldReturnsExpectedResult()
        {
            var name                  = _fixture.Create <DbaseFieldName>();
            var length                = _fixture.GenerateDbaseSingleLength();
            var decimalCount          = _fixture.GenerateDbaseSingleDecimalCount(length);
            var positiveIntegerDigits = decimalCount != new DbaseDecimalCount(0)
                ? new DbaseIntegerDigits(length.ToInt32() - 1 - decimalCount.ToInt32())
                : new DbaseIntegerDigits(length.ToInt32());
            var negativeIntegerDigits = positiveIntegerDigits != new DbaseIntegerDigits(0)
                ? positiveIntegerDigits.Minus(new DbaseIntegerDigits(1))
                : new DbaseIntegerDigits(0);

            var result = DbaseField.CreateFloatField(
                name,
                length,
                decimalCount);

            Assert.Equal(name, result.Name);
            Assert.Equal(DbaseFieldType.Float, result.FieldType);
            Assert.Equal(ByteOffset.Initial, result.Offset);
            Assert.Equal(length, result.Length);
            Assert.Equal(decimalCount, result.DecimalCount);
            Assert.Equal(positiveIntegerDigits, result.PositiveIntegerDigits);
            Assert.Equal(negativeIntegerDigits, result.NegativeIntegerDigits);
        }
        public void CreateSingleFieldThrowsWhenDecimalCountGreaterThanZeroAndLengthSmallerThan3(int smallerThan3)
        {
            var name         = _fixture.Create <DbaseFieldName>();
            var length       = new DbaseFieldLength(smallerThan3);
            var decimalCount = new DbaseDecimalCount(1);

            Assert.Throws <ArgumentException>(() => DbaseField.CreateFloatField(
                                                  name,
                                                  length,
                                                  decimalCount));
        }
        public void CreateSingleFieldThrowsWhenDecimalCountGreaterThanOrEqualToLength(int plus)
        {
            var name         = _fixture.Create <DbaseFieldName>();
            var length       = _fixture.GenerateDbaseSingleLength();
            var decimalCount = new DbaseDecimalCount(length.ToInt32()).Plus(new DbaseDecimalCount(plus));

            Assert.Throws <ArgumentException>(() => DbaseField.CreateFloatField(
                                                  name,
                                                  length,
                                                  decimalCount));
        }
        public void AcceptsInt16ValueReturnsExpectedResult(int length, short value, bool accepted)
        {
            var sut = new DbaseFloat(
                DbaseField.CreateFloatField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length),
                    new DbaseDecimalCount(0)
                    ));

            var result = sut.AcceptsValue(value);

            Assert.Equal(accepted, result);
        }
        public void TrySetValueAsNullableInt16ReturnsExpectedResult(int length, short?value, bool expected)
        {
            var sut = new DbaseFloat(
                DbaseField.CreateFloatField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length),
                    new DbaseDecimalCount(0)
                    ));

            var result = sut.TrySetValueAsNullableInt16(value);

            Assert.Equal(expected, result);
        }
        public void TryGetValueAsInt32ReturnsExpectedResult(int length, float?value, bool gotten, int gottenValueAsInt32)
        {
            var sut = new DbaseFloat(
                DbaseField.CreateFloatField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length),
                    new DbaseDecimalCount(0)
                    ), value);

            var result = sut.TryGetValueAsInt32(out var valueAsInt32);

            Assert.Equal(gotten, result);
            Assert.Equal(gottenValueAsInt32, valueAsInt32);
        }
        public void SetValueAsNullableInt16ReturnsExpectedResult(int length, short?value, bool expected)
        {
            var sut = new DbaseFloat(
                DbaseField.CreateFloatField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length),
                    new DbaseDecimalCount(0)
                    ));

            if (!expected)
            {
                Assert.Throws <FormatException>(() =>
                {
                    sut.ValueAsNullableInt16 = value;
                });
            }
            else
            {
                sut.ValueAsNullableInt16 = value;
            }
        }
        public void GetValueAsNullableInt16ReturnsExpectedResult(int length, float?value, bool gotten, short?gottenValueAsInt16)
        {
            var sut = new DbaseFloat(
                DbaseField.CreateFloatField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length),
                    new DbaseDecimalCount(0)
                    ), value);

            if (!gotten)
            {
                Assert.Throws <FormatException>(() =>
                {
                    var _ = sut.ValueAsNullableInt16;
                });
            }
            else
            {
                var result = sut.ValueAsNullableInt16;
                Assert.Equal(gottenValueAsInt16, result);
            }
        }