Example #1
0
        public void TestGetImportantDataWithDateRange_ParametersAreAdded()
        {
            //setup/arrange
            DbCommand command = new MockDbCommand();
            DBCommandFactory cmdFactory = new MockDBCommandFactory();
            MockDBCommandFactory mockCmdFactory = (MockDBCommandFactory)cmdFactory;
            mockCmdFactory.RespondTo("procImportantDataByRange").With(command);
            Data dataDAL = new InterceptingData(mockCmdFactory);
            InterceptingData interceptingDataDAL = (InterceptingData)dataDAL;
            DateTime fromDate = DateTime.Now;
            DateTime toDate = DateTime.Now;

            //execute/act
            dataDAL.GetImportantDataWithDateRange(fromDate, toDate);

            //assert
            Assert.AreEqual(3, interceptingDataDAL.intercepts.Count); //because of step 3 we had to update this from 2 to 3
            Intercept fromDateAddParameterInterception = interceptingDataDAL.intercepts[0];
            Assert.AreEqual("AddParameter", fromDateAddParameterInterception.MethodName);
            Assert.AreSame(command, fromDateAddParameterInterception.Args[0]);
            Assert.AreEqual("@FromDate", fromDateAddParameterInterception.Args[1]);
            Assert.AreEqual(DbType.String, fromDateAddParameterInterception.Args[2]);
            Assert.AreEqual(fromDate, fromDateAddParameterInterception.Args[3]);

            Intercept toDateAddParameterInterception = interceptingDataDAL.intercepts[1];
            Assert.AreEqual("AddParameter", toDateAddParameterInterception.MethodName);
            Assert.AreSame(command, toDateAddParameterInterception.Args[0]);
            Assert.AreEqual("@ToDate", toDateAddParameterInterception.Args[1]);
            Assert.AreEqual(DbType.String, toDateAddParameterInterception.Args[2]);
            Assert.AreEqual(toDate, toDateAddParameterInterception.Args[3]);
        }
Example #2
0
        public void TestGetImportantDataWithDateRange_ExecuteDataSetIsCalled()
        {
            //setup/arrange
            DbCommand command = new MockDbCommand();
            DBCommandFactory cmdFactory = new MockDBCommandFactory();
            MockDBCommandFactory mockCmdFactory = (MockDBCommandFactory)cmdFactory;
            mockCmdFactory.RespondTo("procImportantDataByRange").With(command);
            Data dataDAL = new InterceptingData(mockCmdFactory);
            InterceptingData interceptingDataDAL = (InterceptingData)dataDAL;
            DateTime fromDate = DateTime.Now;
            DateTime toDate = DateTime.Now;

            //execute/act
            dataDAL.GetImportantDataWithDateRange(fromDate, toDate);

            //assert
            Intercept executeDataSetInterception = interceptingDataDAL.intercepts[2];
            Assert.AreEqual("ExecuteDataSet", executeDataSetInterception.MethodName);
            Assert.AreSame(command, executeDataSetInterception.Args[0]);
        }
Example #3
0
        public void TestGetImportantDataWithDateRange_ReturnesData()
        {
            //setup/arrange
            DbCommand command = new MockDbCommand();
            DBCommandFactory cmdFactory = new MockDBCommandFactory();
            MockDBCommandFactory mockCmdFactory = (MockDBCommandFactory)cmdFactory;
            mockCmdFactory.RespondTo("procImportantDataByRange").With(command);
            Data dataDAL = new InterceptingData(mockCmdFactory);
            InterceptingData interceptingDataDAL = (InterceptingData)dataDAL;
            DateTime fromDate = DateTime.Now;
            DateTime toDate = DateTime.Now;
            DataSet testData = new DataSet();
            interceptingDataDAL.ExecuteDataSetReturnValue = testData;

            //execute/act
            DataSet returnValue = dataDAL.GetImportantDataWithDateRange(fromDate, toDate);

            //assert
            Assert.AreSame(testData, returnValue);
        }