Example #1
0
        public void QueryWithoutEnoughParams()
        {
            SqlParameter sqlParameter1 = new SqlParameter();

            Expect.Call(command.CreateParameter()).Return(sqlParameter1);
            Expect.Call(provider.CreateParameterNameForCollection(COLUMN_NAMES[0])).Return("@" + COLUMN_NAMES[0]);

            SqlParameter sqlParameter2 = new SqlParameter();

            Expect.Call(command.CreateParameter()).Return(sqlParameter2);
            Expect.Call(provider.CreateParameterNameForCollection(COLUMN_NAMES[1])).Return("@" + COLUMN_NAMES[1]);

            mocks.ReplayAll();

            IntMappingAdoQuery query = new IntMappingAdoQuery();

            query.DbProvider = provider;
            query.Sql        = SELECT_ID_WHERE;
            query.DeclaredParameters.Add(COLUMN_NAMES[0], COLUMN_TYPES[0]);
            query.DeclaredParameters.Add(COLUMN_NAMES[1], COLUMN_TYPES[1]);
            query.Compile();
            query.Query();

            mocks.VerifyAll();
        }
Example #2
0
        public void QueryWithoutEnoughParams()
        {
            A.CallTo(() => command.CreateParameter()).ReturnsLazily(() => new SqlParameter());

            A.CallTo(() => provider.CreateParameterNameForCollection(COLUMN_NAMES[0])).Returns("@" + COLUMN_NAMES[0]).Once();
            A.CallTo(() => provider.CreateParameterNameForCollection(COLUMN_NAMES[1])).Returns("@" + COLUMN_NAMES[1]);

            IntMappingAdoQuery query = new IntMappingAdoQuery();

            query.DbProvider = provider;
            query.Sql        = SELECT_ID_WHERE;
            query.DeclaredParameters.Add(COLUMN_NAMES[0], COLUMN_TYPES[0]);
            query.DeclaredParameters.Add(COLUMN_NAMES[1], COLUMN_TYPES[1]);
            query.Compile();
            Assert.Throws <InvalidDataAccessApiUsageException>(() => query.Query());
        }
        public void QueryWithoutEnoughParams()
        {
            SqlParameter sqlParameter1 = new SqlParameter();

            command.Stub(x => x.CreateParameter()).Return(sqlParameter1).Repeat.Once();
            provider.Stub(x => x.CreateParameterNameForCollection(COLUMN_NAMES[0])).Return("@" + COLUMN_NAMES[0]).Repeat.Once();

            SqlParameter sqlParameter2 = new SqlParameter();

            command.Stub(x => x.CreateParameter()).Return(sqlParameter2);
            provider.Stub(x => x.CreateParameterNameForCollection(COLUMN_NAMES[1])).Return("@" + COLUMN_NAMES[1]);

            IntMappingAdoQuery query = new IntMappingAdoQuery();

            query.DbProvider = provider;
            query.Sql        = SELECT_ID_WHERE;
            query.DeclaredParameters.Add(COLUMN_NAMES[0], COLUMN_TYPES[0]);
            query.DeclaredParameters.Add(COLUMN_NAMES[1], COLUMN_TYPES[1]);
            query.Compile();
            Assert.Throws <InvalidDataAccessApiUsageException>(() => query.Query());
        }
Example #4
0
        public void QueryWithoutEnoughParams()
        {
            SqlParameter sqlParameter1 = new SqlParameter();         
            Expect.Call(command.CreateParameter()).Return(sqlParameter1);
            Expect.Call(provider.CreateParameterNameForCollection(COLUMN_NAMES[0])).Return("@" + COLUMN_NAMES[0]);

            SqlParameter sqlParameter2 = new SqlParameter();
            Expect.Call(command.CreateParameter()).Return(sqlParameter2);
            Expect.Call(provider.CreateParameterNameForCollection(COLUMN_NAMES[1])).Return("@" + COLUMN_NAMES[1]);
            
            mocks.ReplayAll();

            IntMappingAdoQuery query = new IntMappingAdoQuery();
            query.DbProvider = provider;
            query.Sql = SELECT_ID_WHERE;
            query.DeclaredParameters.Add(COLUMN_NAMES[0], COLUMN_TYPES[0]);
            query.DeclaredParameters.Add(COLUMN_NAMES[1], COLUMN_TYPES[1]);
            query.Compile();
            query.Query();

            mocks.VerifyAll();
        }
        public void QueryWithoutEnoughParams()
        {
            SqlParameter sqlParameter1 = new SqlParameter();
            command.Stub(x => x.CreateParameter()).Return(sqlParameter1).Repeat.Once();
            provider.Stub(x => x.CreateParameterNameForCollection(COLUMN_NAMES[0])).Return("@" + COLUMN_NAMES[0]).Repeat.Once();

            SqlParameter sqlParameter2 = new SqlParameter();
            command.Stub(x => x.CreateParameter()).Return(sqlParameter2);
            provider.Stub(x => x.CreateParameterNameForCollection(COLUMN_NAMES[1])).Return("@" + COLUMN_NAMES[1]);

            IntMappingAdoQuery query = new IntMappingAdoQuery();
            query.DbProvider = provider;
            query.Sql = SELECT_ID_WHERE;
            query.DeclaredParameters.Add(COLUMN_NAMES[0], COLUMN_TYPES[0]);
            query.DeclaredParameters.Add(COLUMN_NAMES[1], COLUMN_TYPES[1]);
            query.Compile();
            Assert.Throws<InvalidDataAccessApiUsageException>(() => query.Query());
        }