Пример #1
0
        public void Assembly_QualifiedName(string assemblyName, params string[] qualifications)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            Assert.That(assembly.Name, Is.EqualTo("Foo"));
            Assert.That(assembly.Qualifications.Select(x => x.Name + "|" + x.Value), Is.EqualTo(qualifications));
        }
        public void WithoutQualification_Unchanged(string assemblyName, string name)
        {
            var assembly    = InsTypeFactory.ParseAssemblyName(assemblyName);
            var newAssembly = assembly.WithoutQualification(name);

            Assert.That(newAssembly, Is.SameAs(assembly));
        }
        public void GetProcessorArchitecture(string assemblyName, bool success, ProcessorArchitecture processorArchitecture)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            Assert.That(assembly.TryGetProcessorArchitecture(out var architecture), Is.EqualTo(success));
            Assert.That(architecture, Is.EqualTo(processorArchitecture));
        }
Пример #4
0
        public string Assembly_UnqualifiedName(string assemblyName)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            Assert.That(assembly.Qualifications, Is.Empty);

            return(assembly.Name);
        }
        public void GetPublicKey_Invalid(string assemblyName)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            Assert.That(
                () => assembly.TryGetPublicKey(out _),
                Throws.Exception.TypeOf <FormatException>()
                .With.Message.EqualTo("PublicKey qualification was provided, but was in an unrecognised format."));
        }
        public string?TryGetQualification(string name)
        {
            var assembly = InsTypeFactory.ParseAssemblyName("Foo, Bar=A, Baz=B, Quux=C");

            if (!assembly.TryGetQualification(name, out var result))
            {
                return(null);
            }

            return(result ?? "<null>");
        }
Пример #7
0
 public string?Assembly_Invalid(string assemblyName)
 {
     try
     {
         InsTypeFactory.ParseAssemblyName(assemblyName);
         Assert.Fail("Expected to throw an InvalidTypeNameException.");
         return(null);
     }
     catch (InvalidTypeNameException ex)
     {
         return(ex.Message);
     }
 }
        public void GetPublicKey(string assemblyName, bool success, byte[] token)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            if (success)
            {
                Assert.That(assembly.TryGetPublicKey(out var value), Is.True);
                Assert.That(value, Is.EqualTo(token));
            }
            else
            {
                Assert.That(assembly.TryGetPublicKey(out var value), Is.False);
                Assert.That(value, Is.Null);
            }
        }
        public void GetVersion(string assemblyName, string expectedVersion)
        {
            var assembly = InsTypeFactory.ParseAssemblyName(assemblyName);

            if (expectedVersion == null)
            {
                Assert.That(assembly.TryGetVersion(out var version), Is.False);
                Assert.That(version, Is.Null);
            }
            else
            {
                Assert.That(assembly.TryGetVersion(out var version), Is.True);
                Assert.That(version, Is.EqualTo(Version.Parse(expectedVersion)));
            }
        }
 public string WithoutQualification(string assemblyName, string name)
 {
     return(InsFormatter.Format(
                InsTypeFactory.ParseAssemblyName(assemblyName)
                .WithoutQualification(name)));
 }
 public string TryGetProcessorArchitecture(string assemblyName, ProcessorArchitecture processorArchitecture)
 {
     return(InsFormatter.Format(
                InsTypeFactory.ParseAssemblyName(assemblyName)
                .WithProcessorArchitecture(processorArchitecture)));
 }
 public string WithPublicKey(string assemblyName, byte[] publicKey)
 {
     return(InsFormatter.Format(
                InsTypeFactory.ParseAssemblyName(assemblyName)
                .WithPublicKey(publicKey)));
 }
 public string WithVersion(string assemblyName, string version)
 {
     return(InsFormatter.Format(
                InsTypeFactory.ParseAssemblyName(assemblyName)
                .WithVersion(Version.Parse(version))));
 }