Пример #1
0
        public void WhenNoFunctionsExistReturnsOnlyAuditOperationColumn()
        {
            var dialect = new Dialects.DummyExtendedDialect();

            dialect.Functions.Clear();

            var auditColumns = GetAuditColumnSource().GetAuditColumns(
                new Table("AuditTable"), dialect);

            Assert.AreEqual(1, auditColumns.Count());
        }
Пример #2
0
        public void WhenCurrentTimestampFunctionExistsReturnsAuditTimestampColumn()
        {
            var dialect = new Dialects.DummyExtendedDialect();

            dialect.Functions.Clear();
            dialect.Functions.Add(
                AuditColumnSource.CurrentTimestampFunctionName,
                new NoArgSQLFunction("getdate", NHibernateUtil.DateTime));

            var auditColumns = GetAuditColumnSource().GetAuditColumns(
                new Table("AuditTable"), dialect);

            Assert.AreEqual(2, auditColumns.Count());
        }
Пример #3
0
        public void WhenCurrentUserFunctionExistsReturnsAuditUserColumn()
        {
            var dialect = new Dialects.DummyExtendedDialect();

            dialect.Functions.Clear();
            dialect.Functions.Add(
                AuditColumnSource.CurrentUserFunctionName,
                new NoArgSQLFunction("system_user", NHibernateUtil.AnsiString));

            var auditColumns = GetAuditColumnSource().GetAuditColumns(
                new Table("AuditTable"), dialect);

            Assert.AreEqual(2, auditColumns.Count());
        }
Пример #4
0
        public void AuditOperationColumnUniquelyIdentifiesOperation()
        {
            var dialect = new Dialects.DummyExtendedDialect();

            dialect.Functions.Clear();

            var auditColumns = GetAuditColumnSource().GetAuditColumns(
                new Table("AuditTable"), dialect);

            var auditOperation = auditColumns.Single();
            var operations     = new TriggerActions[] {
                TriggerActions.INSERT,
                TriggerActions.UPDATE,
                TriggerActions.DELETE
            };

            var outputs = from op in operations
                          select auditOperation.ValueFunction(op);

            Assert.AreEqual(outputs.Count(), outputs.Distinct().Count());
        }