protected override DbParameter CreateDbParameter()
            {
                var p = new FakeDbParameter();

                _parameters.Add(p);
                return(p);
            }
        public async Task Configures_DbCommand_with_dynamic_parameters(
            Delegate commandDelegate,
            string telemetryName,
            bool async)
        {
            var fakeConnection = CreateConnection();

            var typeMapper = (IRelationalTypeMappingSource) new TestRelationalTypeMappingSource(
                TestServiceFactory.Instance.Create <TypeMappingSourceDependencies>(),
                TestServiceFactory.Instance.Create <RelationalTypeMappingSourceDependencies>());

            var dbParameter = new FakeDbParameter
            {
                ParameterName = "FirstParameter",
                Value         = 17,
                DbType        = DbType.Int32
            };

            var relationalCommand = CreateRelationalCommand(
                parameters: new[]
            {
                new DynamicRelationalParameter("FirstInvariant", "FirstParameter", typeMapper),
                new DynamicRelationalParameter("SecondInvariant", "SecondParameter", typeMapper),
                new DynamicRelationalParameter("ThirdInvariant", "ThirdParameter", typeMapper)
            });

            var parameterValues = new Dictionary <string, object>
            {
                { "FirstInvariant", dbParameter },
                { "SecondInvariant", 18L },
                { "ThirdInvariant", null }
            };

            if (async)
            {
                await((CommandFunc)commandDelegate)(fakeConnection, relationalCommand, parameterValues);
            }
            else
            {
                ((CommandAction)commandDelegate)(fakeConnection, relationalCommand, parameterValues);
            }

            Assert.Equal(1, fakeConnection.DbConnections.Count);
            Assert.Equal(1, fakeConnection.DbConnections[0].DbCommands.Count);
            Assert.Equal(3, fakeConnection.DbConnections[0].DbCommands[0].Parameters.Count);

            var parameter = fakeConnection.DbConnections[0].DbCommands[0].Parameters[0];

            Assert.Equal(parameter, fakeConnection.DbConnections[0].DbCommands[0].Parameters[0]);

            parameter = fakeConnection.DbConnections[0].DbCommands[0].Parameters[1];
            var mapping = typeMapper.FindMapping(18L.GetType());

            Assert.Equal("SecondParameter", parameter.ParameterName);
            Assert.Equal(18L, parameter.Value);
            Assert.Equal(ParameterDirection.Input, parameter.Direction);
            Assert.False(parameter.IsNullable);
            Assert.Equal(mapping.DbType, parameter.DbType);

            parameter = fakeConnection.DbConnections[0].DbCommands[0].Parameters[2];

            Assert.Equal("ThirdParameter", parameter.ParameterName);
            Assert.Equal(DBNull.Value, parameter.Value);
            Assert.Equal(ParameterDirection.Input, parameter.Direction);
            Assert.Equal(FakeDbParameter.DefaultIsNullable, parameter.IsNullable);
            Assert.Equal(FakeDbParameter.DefaultDbType, parameter.DbType);
        }