public async Task Return_from_local_cache() { // Arrange var expectedFile = new AppFile("acme.vanilla", "path", new byte[0]); var connector = new TestableAppsContextConnector("foo", new string[0]); connector.CachedFiles["acme.vanilla:some/file.txt"] = expectedFile; // Act var file = await connector.GetFileAsync("acme.vanilla", "some/file.txt", None); // Assert file.ShouldBeSameAs(expectedFile); }
public async Task Return_from_app_or_sandbox() { // Arrange var connector = new TestableAppsContextConnector("foo", new string[0]) .WithApp(new App("acme", "vanilla", "1.2.3")) .WithFileInAppOrSandbox("acme.vanilla", "1.2.3", "some/file.txt", new byte[] { 1, 2, 3 }); // Act var file = await connector.GetFileAsync("acme.vanilla", "some/file.txt", None); // Assert file.App.ShouldBe("acme.vanilla"); file.Path.ShouldBe("some/file.txt"); file.Content.ShouldBe(new byte[] {1, 2, 3}); connector.CachedFiles["acme.vanilla:some/file.txt"].ShouldBeSameAs(file); }
public async Task Return_from_archive() { // Arrange var archive = new FileList(new Dictionary<string, FileListItem> { ["some/file.txt"] = new FileListItem(AnyHash, AnySize, "abc 123", ContentEncoding.Utf8) }); var connector = new TestableAppsContextConnector("some", new string[0]) .WithApp(new App("acme", "vanilla", "1.2.3")) .WithArchive("acme.vanilla", "1.2.3", archive); // Act var file = await connector.GetFileAsync("acme.vanilla", "some/file.txt", None); // Assert file.App.ShouldBe("acme.vanilla"); file.Path.ShouldBe("some/file.txt"); file.Content.ShouldBe(Encoding.UTF8.GetBytes("abc 123")); connector.CachedFiles["acme.vanilla:some/file.txt"].ShouldBeSameAs(file); }
public void Throw_error_when_file_does_not_exist_in_archive() { // Arrange var archive = new FileList(new Dictionary<string, FileListItem>()); var connector = new TestableAppsContextConnector("some", new string[0]) .WithApp(new App("acme", "vanilla", "1.2.3")) .WithArchive("acme.vanilla", "1.2.3", archive); // Act & Assert Should.Throw<AppFileNotFoundException>(() => connector.GetFileAsync("acme.vanilla", "some/file.txt", None)); }
public void Throw_error_when_file_from_app_or_sandbox_cannot_be_found() { // Arrange var connector = new TestableAppsContextConnector("foo", new string[0]); // Act & Assert Should.Throw<ResourceNotFoundException>(() => connector.GetFileAsync("acme.vanilla", "some/file.txt", None)); }