예제 #1
0
        public void FailsOnInvalidHash(string hash)
        {
            var resolver = new PackageCacheCompilationAssemblyResolver(FileSystemMockBuilder.Empty, CachePath);
            var library = F.Create(hash: hash);

            var exception = Assert.Throws<InvalidOperationException>(() => resolver.TryResolveAssemblyPaths(library, null));
            exception.Message.Should()
                .Contain(library.Hash)
                .And.Contain(library.Name);
        }
예제 #2
0
        public void SkipsNonPackage()
        {
            var resolver = new PackageCacheCompilationAssemblyResolver();
            var library = F.Create(
               F.PackageType,
               assemblies: F.EmptyAssemblies);

            var result = resolver.TryResolveAssemblyPaths(library, null);

            result.Should().BeFalse();
        }
예제 #3
0
        public void ChecksHashFile()
        {
            var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
            var fileSystem = FileSystemMockBuilder.Create()
                .AddFile(
                    Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
                    "WRONGHASH"
                )
                .AddFiles(packagePath, F.DefaultAssemblies)
                .Build();

            var resolver = new PackageCacheCompilationAssemblyResolver(fileSystem, CachePath);
            var assemblies = new List<string>();

            var result = resolver.TryResolveAssemblyPaths(F.Create(), assemblies);
            result.Should().BeFalse();
        }
예제 #4
0
        public void FailsWhenOneOfAssembliesNotFound()
        {
            var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
            var fileSystem = FileSystemMockBuilder.Create()
                .AddFile(
                    Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
                    F.DefaultHashValue
                )
                .AddFiles(packagePath, F.DefaultAssemblyPath)
                .Build();
            var library = F.Create(assemblies: F.TwoAssemblies);

            var resolver = new PackageCacheCompilationAssemblyResolver(fileSystem, CachePath);
            var assemblies = new List<string>();

            var exception = Assert.Throws<InvalidOperationException>(() => resolver.TryResolveAssemblyPaths(library, assemblies));
            exception.Message.Should()
                .Contain(F.SecondAssemblyPath)
                .And.Contain(library.Name);
        }
예제 #5
0
        public void ResolvesAllAssemblies()
        {
            var packagePath = Path.Combine(CachePath, F.DefaultPackageName, F.DefaultVersion);
            var fileSystem = FileSystemMockBuilder.Create()
                .AddFile(
                    Path.Combine(packagePath, $"{F.DefaultPackageName}.{F.DefaultVersion}.nupkg.{F.DefaultHashAlgoritm}"),
                    F.DefaultHashValue
                )
                .AddFiles(packagePath, F.TwoAssemblies)
                .Build();
            var library = F.Create(assemblies: F.TwoAssemblies);

            var resolver = new PackageCacheCompilationAssemblyResolver(fileSystem, CachePath);
            var assemblies = new List<string>();

            var result = resolver.TryResolveAssemblyPaths(library, assemblies);

            assemblies.Should().HaveCount(2);
            assemblies.Should().Contain(Path.Combine(packagePath, F.DefaultAssemblyPath));
            assemblies.Should().Contain(Path.Combine(packagePath, F.SecondAssemblyPath));
        }