public void GetHashCode_EqualObjects_SameHashCodes() { // arrange PluginsConfigXml configOne = new PluginsConfigXml(); PluginsConfigXml configTwo = new PluginsConfigXml(); FileXml file = new FileXml(); file.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location ); file.FileName = "abcdef"; configOne.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>(); configOne.PlugIns.Add( file ); configTwo.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>(); configTwo.PlugIns.Add( file ); int hashCodeOne, hashCodeTwo; // act hashCodeOne = configOne.GetHashCode(); hashCodeTwo = configTwo.GetHashCode(); // assert Assert.AreEqual( hashCodeOne, hashCodeTwo ); }
public void GetHashCode_DifferentDependencies_DifferentHashCodes() { // arrange PluginsConfigXml configOne = new PluginsConfigXml(); PluginsConfigXml configTwo = new PluginsConfigXml(); FileXml file = new FileXml(); FileXml dirOther = new FileXml(); file.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location ); file.FileName = "abcd"; dirOther.Location = System.IO.Path.GetPathRoot( file.Location ); dirOther.FileName = "xyz"; configOne.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>(); configOne.PlugIns.Add( file ); configTwo.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>(); configTwo.PlugIns.Add( file ); configTwo.PlugIns.Add( dirOther ); int hashCodeOne, hashCodeTwo; // act hashCodeOne = configOne.GetHashCode(); hashCodeTwo = configTwo.GetHashCode(); // assert Assert.AreNotEqual( hashCodeOne, hashCodeTwo ); }