Beispiel #1
0
        public void WhenAuditToStringIncludeAllPropertiesYesIncludeErrorProperty()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.Yes, SortOption.AuditSequencePropertyName);

            // assert
            Assert.Equal("FirstName = Oceanware, Count = -1, IsActive = True, Error = Problem", result);
        }
Beispiel #2
0
        public void WhenAuditToStringSortOptionPropertyNameReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.No, SortOption.PropertyName);

            // assert
            Assert.Equal("Count = -1, FirstName = Oceanware, IsActive = True", result);
        }
Beispiel #3
0
        public void WhenAuditToStringAuditFormatNormalReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.No, SortOption.AuditSequencePropertyName, auditFormat: AuditFormat.Normal);

            // assert
            Assert.Equal("First Name ( FirstName ) = Oceanware, Count ( Count ) = -1, Is Active ( IsActive ) = True", result);
        }
Beispiel #4
0
 /// <summary>Builds up a String containing each property and value in the class decorated with the AuditAttribute. The String displays the property name, property friendly name and property value.</summary>
 /// <typeparam name="T">Class type.</typeparam>
 /// <param name="instance">The instance.</param>
 /// <param name="includeAllProperties">The include all properties.</param>
 /// <param name="sortOption">The sort option.</param>
 /// <param name="delimiter">The delimiter.</param>
 /// <param name="defaultValue">
 /// If no class properties are decorated with the <see cref="AuditAttribute"/> and the defaultValue is not null or an empty string, then the default value will be returned.
 /// </param>
 /// <returns>A String containing each property name, friendly name and value, separated by the delimiter and sorted by AuditAttribute.AuditSequence and then property name.</returns>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value includeAllProperties is not defined.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value sortOption is not defined.</exception>
 /// <exception cref="ArgumentNullEmptyWhiteSpaceException">Thrown when delimiter is null, empty, or white space.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value auditFormat is not defined.</exception>
 public String AuditToString <T>(IncludeAllProperties includeAllProperties, SortOption sortOption, String delimiter = Constants.DefaultAuditMessageDelimiter, AuditFormat auditFormat = AuditFormat.Compact, String defaultValue = Constants.AuditDefaultValue)
 {
     return(AuditMessageFactory.AuditToString(this, includeAllProperties, sortOption, delimiter, auditFormat, defaultValue));
 }