Esempio n. 1
0
        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.CreateSingleField(
                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);
        }
Esempio n. 2
0
        public void CreateSingleFieldThrowsWhenDecimalCountGreaterThanZeroAndLengthSmallerThan3(int smallerThan3)
        {
            var name         = _fixture.Create <DbaseFieldName>();
            var length       = new DbaseFieldLength(smallerThan3);
            var decimalCount = new DbaseDecimalCount(1);

            Assert.Throws <ArgumentException>(() => DbaseField.CreateSingleField(
                                                  name,
                                                  length,
                                                  decimalCount));
        }
Esempio n. 3
0
        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.CreateSingleField(
                                                  name,
                                                  length,
                                                  decimalCount));
        }