コード例 #1
0
        public void WhenAuditToIDictionaryAuditFormatNormalReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };
            const Int32 ExpectedDictionaryCount = 3;

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

            // assert
            Assert.True(result.Count == ExpectedDictionaryCount);
            Assert.True("FirstName = Oceanware, Count = -1, IsActive = True" == stringResult);
        }
コード例 #2
0
        public void WhenAuditToIDictionaryIncludeAllPropertiesYesIncludeErrorProperty()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };
            const Int32 ExpectedDictionaryCount = 4;

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

            // assert
            Assert.True(result.Count == ExpectedDictionaryCount);
            Assert.True("FirstName = Oceanware, Count = -1, IsActive = True, Error = Problem" == stringResult);
        }
コード例 #3
0
 /// <summary>Populates the dictionary with property's name and value in the class for properties decorated with the <see cref="AuditAttribute"/>. If <c>IncludeAllProperties.Yes</c> then all properties will be included with or without the <c>AuditAttribute</c>.</summary>
 /// <param name="instance">The instance.</param>
 /// <param name="dictionary">Pass an IDictionary Object that needs to be populated. This could be the Data property of an exception Object that you want to populate, etc.</param>
 /// <param name="includeAllProperties">The include all properties.</param>
 /// <param name="sortOption">The sort option.</param>
 /// <param name="auditFormat">The audit format.</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 a single entry will be added to the dictionary that is named 'DefaultValue' and will have the value of defaultValue.
 /// </param>
 /// <returns>IDictionary populated with properties and values.</returns>
 /// <exception cref="ArgumentNullException">Thrown when dictionary is null.</exception>
 /// <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="InvalidEnumArgumentException">Thrown when enum value auditFormat is not defined.</exception>
 public IDictionary <String, String> AuditToIDictionary(IDictionary <String, String> dictionary, IncludeAllProperties includeAllProperties, SortOption sortOption, AuditFormat auditFormat = AuditFormat.Compact, String defaultValue = Constants.AuditDefaultValue)
 {
     return(AuditMessageFactory.AuditToIDictionary(this, dictionary, includeAllProperties, sortOption, auditFormat, defaultValue));
 }