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);
        }
        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);
        }
        public void DataAccessLayerFacadeCreatesTable()
        {
            Mock <IDbConnection>   connection = MockDbConnection();
            IDataAccessLayerFacade facade     = new DataAccessLayerFacade(() => connection.Object);

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

            Assert.IsNotNull(table);
        }
        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);
        }
        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);
        }
        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);
        }