public static void Resolve___Should_return_null___For_missing_type() { // Arrange var toFind = new TypeDescription("namespace", "name", "assemblyqualifiedname"); // Act var result = toFind.ResolveFromLoadedTypes(); // Assert result.Should().BeNull(); }
public static void Resolve_ThrowOnMultiple___Should_throw___For_multiple_found_types() { // Arrange var testAssemblyRootPath = Path.Combine( new Uri(typeof(TypeDescriptionExtensionsTest).Assembly.CodeBase).LocalPath.Replace( "\\OBeautifulCode.TypeRepresentation.Test.DLL", string.Empty), "..", "..", "TestingAssemblies"); Assembly.LoadFile(Path.Combine(testAssemblyRootPath, "Newtonsoft.Json.8.0.3.testDll")); Assembly.LoadFile(Path.Combine(testAssemblyRootPath, "Newtonsoft.Json.9.0.1.testDll")); var toFind = new TypeDescription("Newtonsoft.Json", "JsonConvert", "FullNameShouldNotBeUsed"); Action action = () => toFind.ResolveFromLoadedTypes(TypeMatchStrategy.NamespaceAndName, MultipleMatchStrategy.ThrowOnMultiple); // Act & Assert action.Should().Throw <InvalidOperationException>(); }
public static void Resolve_Oldest___Should_return_valid_type___For_found_type() { // Arrange var testAssemblyRootPath = Path.Combine( new Uri(typeof(TypeDescriptionExtensionsTest).Assembly.CodeBase).LocalPath.Replace( "\\OBeautifulCode.TypeRepresentation.Test.DLL", string.Empty), "..", "..", "TestingAssemblies"); Assembly.LoadFile(Path.Combine(testAssemblyRootPath, "Newtonsoft.Json.8.0.3.testDll")); Assembly.LoadFile(Path.Combine(testAssemblyRootPath, "Newtonsoft.Json.9.0.1.testDll")); var toFind = new TypeDescription("Newtonsoft.Json", "JsonConvert", "FullNameShouldNotBeUsed"); // Act var result = toFind.ResolveFromLoadedTypes(TypeMatchStrategy.NamespaceAndName, MultipleMatchStrategy.OldestVersion); // Assert result.Should().NotBeNull(); result.Assembly.GetName().Version.ToString(4).Should().Be("8.0.0.0"); }