public void AcceptsDateTimeOffsetValueReturnsExpectedResult(int length, DbaseCharacterOptions options, DateTimeOffset value, bool accepted)
        {
            var sut = new DbaseCharacter(
                DbaseField.CreateCharacterField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length)
                    ), options: options);

            var result = sut.AcceptsValue(value);

            Assert.Equal(accepted, result);
        }
        public void TryGetValueAsDateTimeOffsetReturnsExpectedResult(int length, DbaseCharacterOptions options, string value, bool gotten, DateTimeOffset gottenValueAsDateTimeOffset)
        {
            var sut = new DbaseCharacter(
                DbaseField.CreateCharacterField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length)
                    ), value, options);

            var result = sut.TryGetValueAsDateTimeOffset(out var valueAsDateTime);

            Assert.Equal(gotten, result);
            Assert.Equal(gottenValueAsDateTimeOffset, valueAsDateTime);
        }
        public void TrySetValueAsNullableDateTimeReturnsExpectedResult(int length, DbaseCharacterOptions options,
                                                                       DateTime?value, bool expected)
        {
            var sut = new DbaseCharacter(
                DbaseField.CreateCharacterField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length)
                    ), options: options);

            var result = sut.TrySetValueAsNullableDateTime(value);

            Assert.Equal(expected, result);
        }
        public DbaseCharacter(DbaseField field, string value = null, DbaseCharacterOptions options = null) : base(field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            if (field.FieldType != DbaseFieldType.Character)
            {
                throw new ArgumentException(
                          $"The field {field.Name} 's type must be character to use it as a character field.", nameof(field));
            }

            Options = options ?? DbaseCharacterOptions.Default;
            Value   = value;
        }
        public void SetValueAsNullableDateTimeReturnsExpectedResult(int length, DbaseCharacterOptions options,
                                                                    DateTime?value, bool expected)
        {
            var sut = new DbaseCharacter(
                DbaseField.CreateCharacterField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length)
                    ), options: options);

            if (!expected)
            {
                Assert.Throws <FormatException>(() =>
                {
                    sut.ValueAsNullableDateTime = value;
                });
            }
            else
            {
                sut.ValueAsNullableDateTime = value;
            }
        }
        public void GetValueAsNullableDateTimeReturnsExpectedResult(int length, DbaseCharacterOptions options, string value,
                                                                    bool gotten, DateTime?gottenValueAsDateTime)
        {
            var sut = new DbaseCharacter(
                DbaseField.CreateCharacterField(
                    _fixture.Create <DbaseFieldName>(),
                    new DbaseFieldLength(length)
                    ), value, options);

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