Ejemplo n.º 1
0
        public void ResolveType()
        {
            const string typeName = "Remotion.UnitTests.ServiceLocation.TypeNameTemplateResolverTest, Remotion.UnitTests, Version = <version>";
            var          result   = TypeNameTemplateResolver.ResolveToType(typeName, typeof(TypeNameTemplateResolverTest).Assembly);

            Assert.That(result, Is.SameAs(typeof(TypeNameTemplateResolverTest)));
        }
Ejemplo n.º 2
0
        public void GetTypeName_WithVersionAndKeyToken()
        {
            const string typeName = "Name, Version = <version>, PublicKeyToken = <publicKeyToken>";
            var          result   = TypeNameTemplateResolver.ResolveToTypeName(typeName, _referenceAssembly);

            Assert.That(result, Is.EqualTo("Name, Version = 2.4.6.8, PublicKeyToken = c5c11252695089f8"));
        }
Ejemplo n.º 3
0
        public void GetTypeName_WithUnsignedAssembly()
        {
            var referenceAssembly = CreateReferenceAssembly(new Version(), null);

            const string typeName = "Name, Version = <version>, PublicKeyToken = <publicKeyToken>";
            var          result   = TypeNameTemplateResolver.ResolveToTypeName(typeName, referenceAssembly);

            Assert.That(result, Is.EqualTo("Name, Version = 0.0.0.0, PublicKeyToken = null"));
        }
Ejemplo n.º 4
0
        private static TryGetDisplayName GetLocalizedNameFunc()
        {
#pragma warning disable 618
            var serviceType = TypeNameTemplateResolver.ResolveToType(
                "Remotion.Globalization.ExtensibleEnums.IExtensibleEnumGlobalizationService, Remotion.Globalization.ExtensibleEnums, Version=<version>, Culture=neutral, PublicKeyToken=<publicKeyToken>",
                typeof(ExtensibleEnumExtensions).Assembly);
#pragma warning restore 618
            var method = serviceType.GetMethod("TryGetExtensibleEnumValueDisplayName");
            Assertion.IsNotNull(method, "IExtensibleEnumGlobalizationService does not contain method 'GetExtensibleEnumValueDisplayName'.");

            var service = SafeServiceLocator.Current.GetInstance(serviceType);

            return((TryGetDisplayName)method.CreateDelegate(typeof(TryGetDisplayName), service));
        }
Ejemplo n.º 5
0
 public void ResolveType_WithInvalidTypeName()
 {
     TypeNameTemplateResolver.ResolveToType("Badabing", typeof(TypeNameTemplateResolverTest).Assembly);
 }
Ejemplo n.º 6
0
        public void GetTypeName_WithVersion()
        {
            var result = TypeNameTemplateResolver.ResolveToTypeName("Name, Version = <version>", _referenceAssembly);

            Assert.That(result, Is.EqualTo("Name, Version = 2.4.6.8"));
        }