public void Clone_Always_CreatesDeepClone() { IReadOnlyList <string> exclude = new[] { "a" }; IReadOnlyList <string> excludeFiles = new[] { "b" }; IReadOnlyList <string> include = new[] { "c" }; IReadOnlyList <string> includeFiles = new[] { "d" }; var expectedResult = new IncludeExcludeFiles() { Exclude = exclude, ExcludeFiles = excludeFiles, Include = include, IncludeFiles = includeFiles }; int expectedHashCode = expectedResult.GetHashCode(); IncludeExcludeFiles actualResult = expectedResult.Clone(); int actualHashCode = actualResult.GetHashCode(); Assert.NotSame(expectedResult, actualResult); Assert.Equal(expectedResult, actualResult); Assert.Equal(expectedHashCode, actualHashCode); Assert.NotSame(expectedResult.Exclude, actualResult.Exclude); Assert.Equal(exclude, actualResult.Exclude); Assert.NotSame(expectedResult.ExcludeFiles, actualResult.ExcludeFiles); Assert.Equal(excludeFiles, actualResult.ExcludeFiles); Assert.NotSame(expectedResult.Include, actualResult.Include); Assert.Equal(include, actualResult.Include); Assert.NotSame(expectedResult.IncludeFiles, actualResult.IncludeFiles); Assert.Equal(includeFiles, actualResult.IncludeFiles); }
public void GetHashCode_Always_HashesAllProperties() { IReadOnlyList <string> exclude = new[] { "a" }; IReadOnlyList <string> excludeFiles = new[] { "b" }; IReadOnlyList <string> include = new[] { "c" }; IReadOnlyList <string> includeFiles = new[] { "d" }; int expectedResult = GetExpectedHashCode(exclude, excludeFiles, include, includeFiles); var files = new IncludeExcludeFiles(); Assert.Equal(0, files.GetHashCode()); files.Exclude = exclude; files.ExcludeFiles = excludeFiles; files.Include = include; files.IncludeFiles = includeFiles; int actualResult = files.GetHashCode(); Assert.Equal(expectedResult, actualResult); }