示例#1
0
        public void Executes_DelegateInConstructor_When_Invoked()
        {
            var invoked = false;

            using var wQuery = new WriteQuery <int, int>(_ => invoked = true);
            wQuery.Execute(_db);

            invoked.Should()
            .BeTrue();
        }
示例#2
0
        public void DatabaseIsPassedToDelegate_When_Invoked()
        {
            IDatabase <int, int> passedDb = default;

            using var wQuery = new WriteQuery <int, int>(db => passedDb = db);
            wQuery.Execute(_db);

            passedDb.Should()
            .BeEquivalentTo(_db);
        }
示例#3
0
            /// <summary>
            /// returns undo <see cref="Query"/> array corresponding to queries performed on
            /// <paramref name="auditedTableName"/>, where the i'th undo <see cref="Query"/> in result
            /// corresponds the i'th row in <paramref name="auditTableResultSet"/>.
            /// </summary>
            /// <seealso cref="getUndoQuery(ResultSet.Row, string, Dictionary{long, Query.eQueryType})"/>
            /// <param name="auditTableResultSet"></param>
            /// <param name="auditedTableName"></param>
            /// <param name="queryTypeIdToQueryType"></param>
            /// <returns>
            /// undo <see cref="Query"/> array corresponding to queries performed on
            /// <paramref name="auditedTableName"/>, where the i'th undo <see cref="Query"/> in result
            /// corresponds the i'th row in <paramref name="auditTableResultSet"/>
            /// </returns>
            /// <exception cref="UnsupportedAuditQueryTypeException">
            /// <seealso cref="getUndoQuery(ResultSet.Row, string, Dictionary{long, Query.eQueryType})"/>
            /// </exception>
            internal static WriteQuery[] GetAuditTableUndoWriteQueries(
                ResultSet auditTableResultSet,
                string auditedTableName,
                Dictionary <long, Query.eQueryType> queryTypeIdToQueryType)
            {
                WriteQuery[] undoQueries = new WriteQuery[auditTableResultSet.RowCount];

                for (int i = 0; i < auditTableResultSet.RowCount; i++)
                {
                    ResultSet.Row auditTableRow = auditTableResultSet.Rows[i];
                    WriteQuery    undoQuery     = getUndoQuery(
                        auditTableRow,
                        auditedTableName,
                        queryTypeIdToQueryType);

                    undoQueries[i] = undoQuery;
                }

                return(undoQueries);
            }
示例#4
0
        private void RunWriteQuery(WriteQuery wq)
        {
            HtmlNode node;
            bool     inscope = Scope.TryGetValue(wq.Write.Value.AsString(), out node);

            if (inscope)
            {
                try
                {
                    node.WriteTo(XmlWriter.Create(wq.To.Value.AsString()));
                }
                catch (Exception e)
                {
                    throw new ScrapeQLRunnerException("Could not write to file.", e);
                }
            }
            else
            {
                throw new ScrapeQLRunnerException(String.Format("Identifier '{0}' is not in scope at: \n\t{1}", wq.Write.Value.AsString(), wq.Write.Location.AsString()));
            }
        }