コード例 #1
0
        public void DataAccessLayerFacadeCreatesTableWithExpectedNumberOfRows()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

            var table = facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.AreEqual(NumberOfRows, table.Rows.Count);
        }
コード例 #2
0
        public void DataAccessLayerFacadeCreatesTableWithCorrectName()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

            var table = facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.AreEqual(TableName, table.TableName);
        }
コード例 #3
0
        public void DataAccessLayerFacadeCreatesTable()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

            var table = facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.IsNotNull(table);
        }
コード例 #4
0
        public void DataAccessLayerFacadeCreatesTableWithExceptedColumnTypes()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

            var table = facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.AreEqual(typeof(int), table.Columns[0].DataType);
            Assert.AreEqual(typeof(string), table.Columns[1].DataType);
            Assert.AreEqual(typeof(double), table.Columns[2].DataType);
        }
コード例 #5
0
        public void DataAccessLayerFacadeCreatesTableWithExceptedColumnNames()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

            var table = facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.AreEqual("Id", table.Columns[0].ColumnName);
            Assert.AreEqual("Name", table.Columns[1].ColumnName);
            Assert.AreEqual("Salary", table.Columns[2].ColumnName);
        }
コード例 #6
0
        public void DataAccessLaterFacadeThrowsWhenRetryCountIsExceeded()
        {
            int retryCount = 0;

            Mock <IDbConnection> connection = new Mock <IDbConnection>();

            connection.Setup(c => c.CreateCommand()).Callback(() => retryCount++).Throws(new DbExceptionStub());
            IDataAccessLayerFacade facade = new DataAccessLayerFacade(() => connection.Object);

            facade.FillTable("SELECT * FROM Anywhere", TableName);

            Assert.AreEqual(3, retryCount);
        }