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 IncludeExcludeFilesCloneTest() { //Set up var exclude = new List <string>() { "Exlclude0" }; var include = new List <string>() { "Include0" }; var includeFiles = new List <string>() { "IncludeFiles0" }; var excludeFiles = new List <string>() { "ExlcludeFiles0" }; var files = new IncludeExcludeFiles(); files.Exclude = exclude; files.Include = include; files.IncludeFiles = includeFiles; files.ExcludeFiles = excludeFiles; // Act var clone = files.Clone(); //Assert Assert.Equal(files.Exclude, clone.Exclude); Assert.Equal(files.Include, clone.Include); Assert.Equal(files.IncludeFiles, clone.IncludeFiles); Assert.Equal(files.ExcludeFiles, clone.ExcludeFiles); // Act again exclude.Add("Extra Exclude"); //Assert Assert.Equal(2, files.Exclude.Count); Assert.NotEqual(files.Exclude, clone.Exclude); }