public async Task It_does_not_track_extensions_that_are_not_file_providers(Language language) { var kernel = CreateKernel(language); var provider = new FileProvider(kernel); var projectDir = DirectoryUtility.CreateDirectory(); var packageName = $"MyTestExtension.{Path.GetRandomFileName()}"; var packageVersion = "2.0.0-" + Guid.NewGuid().ToString("N"); var guid = Guid.NewGuid().ToString(); var nupkg = await KernelExtensionTestHelper.CreateExtensionNupkg( projectDir, $"await kernel.SendAsync(new SubmitCode(\"\\\"{guid}\\\"\"));", packageName, packageVersion); await kernel.SubmitCodeAsync($@" #i ""nuget:{nupkg.Directory.FullName}"" #r ""nuget:{packageName},{packageVersion}"" "); Action action = () => provider.GetFileInfo("extensions/TestKernelExtension/resources/file.txt"); action.Should().Throw <StaticContentSourceNotFoundException>(); }
public async Task It_tracks_extensions_that_are_not_file_providers(Language language) { var kernel = CreateKernel(language); var provider = new FileProvider(kernel); var projectDir = DirectoryUtility.CreateDirectory(); var fileToEmbed = new FileInfo(Path.Combine(projectDir.FullName, "file.txt")); File.WriteAllText(fileToEmbed.FullName, "for testing only"); var packageName = $"MyTestExtension.{Path.GetRandomFileName()}"; var packageVersion = "2.0.0-" + Guid.NewGuid().ToString("N"); var guid = Guid.NewGuid().ToString(); var nupkg = await KernelExtensionTestHelper.CreateExtensionNupkg( projectDir, $"await kernel.SendAsync(new SubmitCode(\"\\\"{guid}\\\"\"));", packageName, packageVersion, fileToEmbed); await kernel.SubmitCodeAsync($@" #i ""nuget:{nupkg.Directory.FullName}"" #r ""nuget:{packageName},{packageVersion}"" "); var file = provider.GetFileInfo("extensions/TestKernelExtension/resources/file.txt"); file.Should() .NotBeNull(); }
public async Task can_get_static_content_from_extensions() { var server = GetServer(); var kernel = server.Kernel; var projectDir = DirectoryUtility.CreateDirectory(); var fileToEmbed = new FileInfo(Path.Combine(projectDir.FullName, "file.txt")); File.WriteAllText(fileToEmbed.FullName, "for testing only"); var packageName = $"MyTestExtension.{Path.GetRandomFileName()}"; var packageVersion = "2.0.0-" + Guid.NewGuid().ToString("N"); var guid = Guid.NewGuid().ToString(); var nupkg = await KernelExtensionTestHelper.CreateExtensionNupkg( projectDir, $"await kernel.SendAsync(new SubmitCode(\"\\\"{guid}\\\"\"));", packageName, packageVersion, fileToEmbed); await kernel.SubmitCodeAsync($@" #i ""nuget:{nupkg.Directory.FullName}"" #r ""nuget:{packageName},{packageVersion}"" "); var response = await server.HttpClient.GetAsync("extensions/TestKernelExtension/resources/file.txt"); await response.ShouldSucceed(); response.Content.Headers.ContentType.MediaType.Should().Be("text/plain"); }