Example #1
0
        public void Test_Basic_Constructor()
        {
            // ARRANGE
            Guid                  paramId             = Guid.NewGuid();
            Guid                  paramAuditHeaderId  = Guid.NewGuid();
            const string          paramTableName      = "TableName";
            const string          paramColumnName     = "ColumnName";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "new Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            AuditDetailDto auditDetailDto = new AuditDetailDto(
                id: paramId,
                auditHeaderId: paramAuditHeaderId,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction);

            // ASSERT
            Assert.AreEqual(paramId, auditDetailDto.Id);
            Assert.AreEqual(paramAuditHeaderId, auditDetailDto.AuditHeaderId);
            Assert.AreEqual(paramTableName, auditDetailDto.TableName);
            Assert.AreEqual(paramColumnName, auditDetailDto.ColumnName);
            Assert.AreEqual(paramRecordId, auditDetailDto.RecordId);
            Assert.AreEqual(paramOldValue, auditDetailDto.OldValue);
            Assert.AreEqual(paramNewValue, auditDetailDto.NewValue);
            Assert.AreEqual(paramDatabaseAction, auditDetailDto.DatabaseAction);
            Assert.IsNull(auditDetailDto.AuditHeader);
        }
Example #2
0
        public void TestWithValidValuesThatAreNull()
        {
            // ARRANGE
            Guid                  paramId             = Guid.NewGuid();
            IAuditHeader          paramAuditHeader    = Create.AuditHeader();
            const string          paramTableName      = "Organisation";
            const string          paramColumnName     = "Id";
            Guid                  paramRecordId       = Guid.NewGuid();
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            IAuditDetail auditDetail = new AuditDetail(
                id: paramId,
                auditHeader: paramAuditHeader,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: null,
                newValue: null,
                databaseAction: paramDatabaseAction);

            // ASSERT
            Assert.IsNull(auditDetail.OldValue);
            Assert.IsNull(auditDetail.NewValue);
        }
Example #3
0
        public void TestWithValidValues()
        {
            // ARRANGE
            Guid                  paramId             = Guid.NewGuid();
            IAuditHeader          paramAuditHeader    = Create.AuditHeader();
            const string          paramTableName      = "Organisation";
            const string          paramColumnName     = "Id";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "New Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            IAuditDetail auditDetail = new AuditDetail(
                id: paramId,
                auditHeader: paramAuditHeader,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction);

            // ASSERT
            Assert.AreEqual(paramId, auditDetail.Id);
            Assert.AreSame(paramAuditHeader, auditDetail.AuditHeader);
            Assert.AreEqual(paramTableName, auditDetail.TableName);
            Assert.AreEqual(paramColumnName, auditDetail.ColumnName);
            Assert.AreEqual(paramRecordId, auditDetail.RecordId);
            Assert.AreEqual(paramOldValue, auditDetail.OldValue);
            Assert.AreEqual(paramNewValue, auditDetail.NewValue);
            Assert.AreEqual(paramDatabaseAction, auditDetail.DatabaseAction);
        }
Example #4
0
 public AuditDetailDto(
     Guid id,
     Guid auditHeaderId,
     string tableName,
     string columnName,
     Guid recordId,
     string? oldValue,
     string? newValue,
     EDatabaseAction databaseAction)
 {
     this.Id = id;
     this.AuditHeaderId = auditHeaderId;
     this.TableName = tableName;
     this.ColumnName = columnName;
     this.RecordId = recordId;
     this.OldValue = oldValue;
     this.NewValue = newValue;
     this.DatabaseAction = databaseAction;
 }
Example #5
0
        public void Test_Full_Constructor()
        {
            // ARRANGE
            Guid           paramId             = Guid.NewGuid();
            AuditHeaderDto paramAuditHeaderDto = new AuditHeaderDto(
                Guid.NewGuid(),
                EAuditEvent.OrganisationMaintenance,
                DateTime.Now,
                "Steve.Wright",
                Guid.NewGuid(),
                new List <AuditDetailDto>());
            const string          paramTableName      = "TableName";
            const string          paramColumnName     = "ColumnName";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "new Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            AuditDetailDto auditDetailDto = new AuditDetailDto(
                id: paramId,
                auditHeaderId: paramAuditHeaderDto.Id,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction,
                auditHeader: paramAuditHeaderDto);

            // ASSERT
            Assert.AreEqual(paramId, auditDetailDto.Id);
            Assert.AreEqual(paramAuditHeaderDto.Id, auditDetailDto.AuditHeaderId);
            Assert.AreEqual(paramTableName, auditDetailDto.TableName);
            Assert.AreEqual(paramColumnName, auditDetailDto.ColumnName);
            Assert.AreEqual(paramRecordId, auditDetailDto.RecordId);
            Assert.AreEqual(paramOldValue, auditDetailDto.OldValue);
            Assert.AreEqual(paramNewValue, auditDetailDto.NewValue);
            Assert.AreEqual(paramDatabaseAction, auditDetailDto.DatabaseAction);
            Assert.AreEqual(paramAuditHeaderDto, auditDetailDto.AuditHeader);
        }
Example #6
0
        public void TestEmptyAuditDetailIdThrowsException()
        {
            // ARRANGE
            IAuditHeader          paramAuditHeader    = Create.AuditHeader();
            const string          paramTableName      = "Organisation";
            const string          paramColumnName     = "Id";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "New Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            _ = new AuditDetail(
                id: Guid.Empty,
                auditHeader: paramAuditHeader,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction);
        }
Example #7
0
        public void TestNullAuditHeaderThrowsException()
        {
            // ARRANGE
            Guid                  paramId             = Guid.NewGuid();
            const string          paramTableName      = "Organisation";
            const string          paramColumnName     = "Id";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "New Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            _ = new AuditDetail(
                id: paramId,
                auditHeader: null !,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction);
        }
Example #8
0
        public void TestLongTableNameThrowsException()
        {
            // ARRANGE
            Guid                  paramId             = Guid.NewGuid();
            IAuditHeader          paramAuditHeader    = Create.AuditHeader();
            string                paramTableName      = new string('x', 500);
            const string          paramColumnName     = "Id";
            Guid                  paramRecordId       = Guid.NewGuid();
            const string          paramOldValue       = "Old Value";
            const string          paramNewValue       = "New Value";
            const EDatabaseAction paramDatabaseAction = EDatabaseAction.Update;

            // ACT
            _ = new AuditDetail(
                id: paramId,
                auditHeader: paramAuditHeader,
                tableName: paramTableName,
                columnName: paramColumnName,
                recordId: paramRecordId,
                oldValue: paramOldValue,
                newValue: paramNewValue,
                databaseAction: paramDatabaseAction);
        }