public void CompareTo() { // For each pair of assembly strings... foreach (string assemblyString1 in s_assemblyStrings) { AssemblyName baseName1 = new AssemblyName(assemblyString1); foreach (string assemblyString2 in s_assemblyStrings) { AssemblyName baseName2 = new AssemblyName(assemblyString2); // ...and for each pair of production methods... foreach (ProduceAssemblyNameEx produce1 in s_producers) { foreach (ProduceAssemblyNameEx produce2 in s_producers) { AssemblyNameExtension a1 = produce1(assemblyString1); AssemblyNameExtension a2 = produce2(assemblyString2); int result = a1.CompareTo(a2); if (a1.Equals(a2)) { Assert.Equal(0, result); } if (a1.CompareBaseNameTo(a2) != 0) { Assert.Equal(a1.CompareBaseNameTo(a2), result); } if ( a1.CompareBaseNameTo(a2) == 0 && // Only check version if basenames match a1.Version != a2.Version ) { if (a1.Version == null) { // Expect -1 if a1.Version is null and the baseNames match Assert.Equal(-1, result); } else { Assert.Equal(a1.Version.CompareTo(a2.Version), result); } } int resultBaseline = String.Compare(a1.FullName, a2.FullName, StringComparison.OrdinalIgnoreCase); // Only check to see if the result and the resultBaseline match when the result baseline is 0 and the result is not 0. if (resultBaseline != result && resultBaseline == 0) { Assert.Equal(resultBaseline, result); } } } } } }
public void CompareBaseName() { // For each pair of assembly strings... foreach (string assemblyString1 in s_assemblyStrings) { AssemblyName baseName1 = new AssemblyName(assemblyString1); foreach (string assemblyString2 in s_assemblyStrings) { AssemblyName baseName2 = new AssemblyName(assemblyString2); // ...and for each pair of production methods... foreach (ProduceAssemblyNameEx produce1 in s_producers) { foreach (ProduceAssemblyNameEx produce2 in s_producers) { AssemblyNameExtension a1 = produce1(assemblyString1); AssemblyNameExtension a2 = produce2(assemblyString2); int result = a1.CompareBaseNameTo(a2); int resultBaseline = String.Compare(baseName1.Name, baseName2.Name, StringComparison.OrdinalIgnoreCase); if (resultBaseline != result) { Assert.Equal(resultBaseline, result); } } } } } }
public void CompareBaseNameRealCase1() { AssemblyNameExtension a1 = ProduceAsBoth("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AssemblyNameExtension a2 = ProduceAsString("System.Drawing"); int result = a1.CompareBaseNameTo(a2); // Base names should be equal. Assert.Equal(0, result); }