public async Task Return_from_cache()
            {
                // Arrange
                var appsClient = Mock.Of<IAppsClient>();
                var sandboxesClient = Mock.Of<ISandboxesClient>();
                var descriptors = new[]
                {
                    new AppFileDescriptor("acme.vanilla", "a", "A", 1),
                    new AppFileDescriptor("acme.vanilla", "b", "B", 2),
                    new AppFileDescriptor("acme.vanilla", "c", "C", 3),
                };

                var connector = new TestableAppsContextConnector(appsClient, sandboxesClient, null);
                connector.CachedFileLists["acme.vanilla"] = descriptors;

                // Act
                var files = await connector.ListFilesAsync("acme.vanilla", "1.2.3");

                // Assert
                files.ShouldBeSameAs(descriptors);
            }
            public void Resource_not_found_should_throw_error()
            {
                // Arrange
                var appsClient = Mock.Of<IAppsClient>();
                appsClient.Setup(x => x.ListFilesAsync("acme.vanilla", "1.2.3", It.IsAny<FileListingOptions>(), None))
                    .ThrowsAsync(new ResourceNotFoundException("bla"));
                var sandboxesClient = Mock.Of<ISandboxesClient>();

                var connector = new TestableAppsContextConnector(appsClient, sandboxesClient, null);

                // Act & Assert
                Should.Throw<ResourceNotFoundException>(() =>
                    connector.ListFilesAsync("acme.vanilla", "1.2.3"));
            }
            public async Task Return_from_sandbox()
            {
                // Arrange
                var archive = new FileList(new Dictionary<string, FileListItem>
                {
                    ["a"] = new FileListItem("A", 1, AnyContent, AnyEncoding),
                    ["b"] = new FileListItem("B", 2, AnyContent, AnyEncoding),
                    ["c"] = new FileListItem("C", 3, AnyContent, AnyEncoding)
                });
                var appsClient = Substitute.For<IAppsClient>();
                var sandboxesClient = Substitute.For<ISandboxesClient>();
                sandboxesClient.ListFilesAsync("acme", "cool", "vanilla", Arg.Any<FileListingOptions>(), None)
                    .Returns(Task.FromResult(archive));
                
                var sandboxes = new SandboxCollection(new[] {new Sandbox("acme", "cool", new[] {"vanilla"})});
                var connector = new TestableAppsContextConnector(appsClient, sandboxesClient, sandboxes);

                // Act
                var files = await connector.ListFilesAsync("acme.vanilla", "1.2.3");

                // Assert
                files.ShouldBe(new[]
                {
                    new AppFileDescriptor("acme.vanilla", "a", "A", 1),
                    new AppFileDescriptor("acme.vanilla", "b", "B", 2),
                    new AppFileDescriptor("acme.vanilla", "c", "C", 3),
                });
                connector.CachedFileLists["acme.vanilla"].ShouldBe(files);
            }