Beispiel #1
0
 public void CanLoadDependeciesWithSubdependencies()
 {
     CreateAssembly(
         "",
         "sub",
         new Version(1, 2, 3))
     .VerifyDiagnostics()
     .VerifyEmit(testEmittedAssembly: (_, subDependency, subDependencyBytes) =>
     {
         var name    = "a";
         var version = new Version(1, 2, 3);
         CreateAssembly(
             "",
             name,
             version)
         .VerifyDiagnostics()
         .VerifyEmit(testEmittedAssembly: (original, assembly, assemblyBytes) =>
         {
             var assemblyLoadContext = new AssemblyLoadContext(null, true);
             var assemblyLoader      = new MockAssemblyLoader(
                 new AssemblyLoadResult(subDependency, subDependencyBytes),
                 new AssemblyLoadResult(assembly, assemblyBytes));
             var dependencyLoader = new DependencyLoader(
                 ImmutableArray.Create <IAssemblyLoader>(assemblyLoader),
                 new DependencyAttributeReader(),
                 _assemblyFactory,
                 GetLogger <DependencyLoader>());
             var dependencies = dependencyLoader.LoadDependenciesAsync(
                 new ProjectInfo(
                     "p",
                     new flc.ProjectSystem.Version(0, 0),
                     ImmutableArray.Create(""),
                     references: ImmutableArray.Create(new Reference(
                                                           Reference.ReferenceType.Assembly,
                                                           name,
                                                           version.ToString()))),
                 assemblyLoadContext,
                 Array.Empty <IAssembly>()).Result;
             var dependency = dependencies.Single();
             Assert.Equal(original.Name, dependency.Name);
             Assert.Equal(original.Version, dependency.Version);
         });
     });
 }
Beispiel #2
0
        public void ThrowsIfSubDependencyNotInAnyAssemblyLoader()
        {
            var subDependency = CreateAssembly("");
            var name          = "a";
            var version       = new Version(1, 2, 3);

            CreateAssembly(
                "",
                name,
                version,
                subDependency)
            .VerifyDiagnostics()
            .VerifyEmit(testEmittedAssembly: (original, assembly, assemblyBytes) =>
            {
                var assemblyLoadContext = new AssemblyLoadContext(null, true);
                var assemblyLoader      = new MockAssemblyLoader(
                    new AssemblyLoadResult(assembly, assemblyBytes));
                var dependencyLoader = new DependencyLoader(
                    ImmutableArray.Create <IAssemblyLoader>(assemblyLoader),
                    new DependencyAttributeReader(),
                    _assemblyFactory,
                    GetLogger <DependencyLoader>());
                Assert.Throws <FlcException>(() => dependencyLoader.LoadDependenciesAsync(
                                                 new ProjectInfo(
                                                     "p",
                                                     new flc.ProjectSystem.Version(0, 0),
                                                     ImmutableArray.Create(""),
                                                     references: ImmutableArray.Create(new Reference(
                                                                                           Reference.ReferenceType.Assembly,
                                                                                           name,
                                                                                           version.ToString()))),
                                                 assemblyLoadContext,
                                                 Array.Empty <IAssembly>()).Result);
            });
        }