コード例 #1
0
        /// <summary>
        ///   Constructs a new <see cref="PrimitiveExtractionStep"/>.
        /// </summary>
        /// <param name="extractor">
        ///   The <see cref="IFieldExtractor"/> defining how the primitive value is to be obtained.
        /// </param>
        /// <param name="converter">
        ///   A <see cref="DataConverter"/> defining how to transform the primitive value extracted according to
        ///   <paramref name="extractor"/>. If no transformation is desired, an
        ///   <see cref="DataConverter.Identity{T}">identity conversion</see> should be provided.
        /// </param>
        /// <pre>
        ///   The <see cref="DataConverter.SourceType">SourceType</see> of <paramref name="converter"/> is the same as
        ///   the <see cref="IFieldExtractor.FieldType">FieldType</see> of <paramref name="extractor"/>, or is a base
        ///   class or interface thereof
        ///     --and--
        ///   The <see cref="IFieldExtractor.FieldType">FieldType</see> of <paramref name="extractor"/> is a data type
        ///   supported by the Framework.
        /// </pre>
        public PrimitiveExtractionStep(IFieldExtractor extractor, DataConverter converter)
        {
            Guard.Against.Null(extractor, nameof(extractor));
            Guard.Against.Null(converter, nameof(converter));
            Debug.Assert(extractor.FieldType.IsInstanceOf(converter.SourceType));
            Debug.Assert(DBType.IsSupported(converter.SourceType));

            extractor_     = extractor;
            converter_     = converter;
            ExpectedSource = extractor_.ExpectedSource;
        }
コード例 #2
0
        /// <summary>
        ///   Constructs a new <see cref="DecomposingExtractionStep"/>.
        /// </summary>
        /// <param name="extractor">
        ///   The <see cref="IFieldExtractor"/> defining how the primitive value is to be obtained.
        /// </param>
        /// <param name="decomposition">
        ///   The steps defining how to decompose the value produced by <paramref name="extractor"/>.
        /// </param>
        /// <pre>
        ///  <paramref name="decomposition"/> is not empty
        ///    --and--
        ///   The <see cref="IExtractionStep.ExpectedSource">ExpectedSource</see> of each element of
        ///   <paramref name="decomposition"/> is the same as the <see cref="IFieldExtractor.FieldType">FieldType</see>
        ///   of <paramref name="extractor"/>, or is a base class or interface thereof
        ///     --and--
        ///   The <see cref="IFieldExtractor.FieldType">FieldType</see> of <paramref name="extractor"/> is a data type
        ///   not supported by the Framework.
        /// </pre>
        public DecomposingExtractionStep(IFieldExtractor extractor, IEnumerable <IExtractionStep> decomposition)
        {
            Guard.Against.Null(extractor, nameof(extractor));
            Guard.Against.Null(decomposition, nameof(decomposition));
            Debug.Assert(!decomposition.IsEmpty());
            Debug.Assert(decomposition.All(d => extractor.FieldType.IsInstanceOf(d.ExpectedSource)));
            Debug.Assert(!DBType.IsSupported(extractor.FieldType));         // otherwise decomposition is unnecessary

            extractor_     = extractor;
            decomposition_ = decomposition;
            ExpectedSource = extractor_.ExpectedSource;
        }
コード例 #3
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupNullableDecimal()
        {
            // Arrange
            var type = typeof(decimal?);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Decimal);
        }
コード例 #4
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupUShort()
        {
            // Arrange
            var type = typeof(ushort);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.UInt16);
        }
コード例 #5
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupNullableEnum()
        {
            // Arrange
            var type = typeof(DataAccessMethod?);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Enumeration);
        }
コード例 #6
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupNullableSbyte()
        {
            // Arrange
            var type = typeof(sbyte?);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Int8);
        }
コード例 #7
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupNullableFloat()
        {
            // Arrange
            var type = typeof(float?);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Single);
        }
コード例 #8
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupNullableULong()
        {
            // Arrange
            var type = typeof(ulong?);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.UInt64);
        }
コード例 #9
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupChar()
        {
            // Arrange
            var type = typeof(char);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Character);
        }
コード例 #10
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupBool()
        {
            // Arrange
            var type = typeof(bool);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Boolean);
        }
コード例 #11
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupString()
        {
            // Arrange
            var type = typeof(string);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.Text);
        }
コード例 #12
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupDateTime()
        {
            // Arrange
            var type = typeof(DateTime);

            // Act
            var supported = DBType.IsSupported(type);
            var dbType    = DBType.Lookup(type);

            // Assert
            supported.Should().BeTrue();
            dbType.Should().Be(DBType.DateTime);
        }
コード例 #13
0
ファイル: DBType.cs プロジェクト: justin-millman/Kvasir
        [TestMethod] public void LookupCollection()
        {
            // Arrange
            var type = typeof(List <string>);

            // Act
            var           supported = DBType.IsSupported(type);
            Func <DBType> action    = () => DBType.Lookup(type);

            // Assert
            supported.Should().BeFalse();
            action.Should().ThrowExactly <ArgumentException>()
            .WithAnyMessage()
            .And
            .ParamName.Should().NotBeNullOrEmpty();
        }