Exemple #1
0
        public void Can_add_composite_parameter()
        {
            var typeMapper = new TestRelationalTypeMappingSource(
                TestServiceFactory.Instance.Create <TypeMappingSourceDependencies>(),
                TestServiceFactory.Instance.Create <RelationalTypeMappingSourceDependencies>());

            var parameterBuilder = new RelationalCommandBuilder(
                new RelationalCommandBuilderDependencies(
                    typeMapper));

            parameterBuilder.AddCompositeParameter(
                "CompositeInvariant",
                new List <IRelationalParameter>
            {
                new TypeMappedRelationalParameter(
                    "FirstInvariant",
                    "FirstName",
                    new IntTypeMapping("int", DbType.Int32),
                    nullable: false),
                new TypeMappedRelationalParameter(
                    "SecondInvariant",
                    "SecondName",
                    new StringTypeMapping("nvarchar(max)"),
                    nullable: true)
            });

            Assert.Equal(1, parameterBuilder.Parameters.Count);

            var parameter = parameterBuilder.Parameters[0] as CompositeRelationalParameter;

            Assert.NotNull(parameter);
            Assert.Equal("CompositeInvariant", parameter.InvariantName);
            Assert.Equal(2, parameter.RelationalParameters.Count);
        }
Exemple #2
0
        public void Does_not_add_empty_composite_parameter()
        {
            var typeMapper = new TestRelationalTypeMappingSource(
                TestServiceFactory.Instance.Create <TypeMappingSourceDependencies>(),
                TestServiceFactory.Instance.Create <RelationalTypeMappingSourceDependencies>());

            var parameterBuilder = new RelationalCommandBuilder(
                new RelationalCommandBuilderDependencies(
                    typeMapper));

            parameterBuilder.AddCompositeParameter(
                "CompositeInvariant",
                new List <IRelationalParameter>());

            Assert.Equal(0, parameterBuilder.Parameters.Count);
        }