Skip to content

Commit

Permalink
Add manual test project
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanFeldman committed Aug 22, 2018
1 parent 5a902a6 commit 9432ec1
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/KeyVaultProvider.TestApp/KeyVaultProvider.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Remove="KeyVaultProvider.TestApp.csproj.DotSettings" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBus.AttachmentPlugin" Version="[3.0.0-*, )" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="[3.*, )" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\KeyVaultProvider\KeyVaultProvider.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary>
39 changes: 39 additions & 0 deletions src/KeyVaultProvider.TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Core;
using Microsoft.Azure.ServiceBus.Management;
using ServiceBus.AttachmentPlugin;

namespace KeyVaultProviderTestApp
{
class Program
{
static async Task Main(string[] args)
{
var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString");
var managementClient = new ManagementClient(connectionString);
if (!await managementClient.QueueExistsAsync("attachments"))
{
await managementClient.CreateQueueAsync("attachments");
}

var queueClient = new QueueClient(connectionString, "attachments", ReceiveMode.ReceiveAndDelete);

var configuration = new AzureStorageAttachmentConfiguration(new KeyVaultProvider("https://keyvaultplugin.vault.azure.net/secrets/storage-connection-string"));

queueClient.RegisterAzureStorageAttachmentPlugin(configuration);
await queueClient.SendAsync(new Message(Encoding.UTF8.GetBytes("hello")));

var messageReceiver = new MessageReceiver(connectionString, "attachments", ReceiveMode.ReceiveAndDelete);
messageReceiver.RegisterAzureStorageAttachmentPlugin(configuration);

var message = await messageReceiver.ReceiveAsync(TimeSpan.FromSeconds(3));

Console.WriteLine($"Received message with body: {Encoding.UTF8.GetString(message.Body)}");

Console.ReadLine();
}
}
}
6 changes: 6 additions & 0 deletions src/ServiceBus.AttachmentPlugin.KeyVaultProvider.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KeyVaultProvider.Tests", "KeyVaultProvider.Tests\KeyVaultProvider.Tests.csproj", "{849A44A8-076D-4C16-8E7C-A65D9481094A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KeyVaultProvider.TestApp", "KeyVaultProvider.TestApp\KeyVaultProvider.TestApp.csproj", "{585D937E-88FE-48C7-84EE-B2764798B903}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{849A44A8-076D-4C16-8E7C-A65D9481094A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{849A44A8-076D-4C16-8E7C-A65D9481094A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{849A44A8-076D-4C16-8E7C-A65D9481094A}.Release|Any CPU.Build.0 = Release|Any CPU
{585D937E-88FE-48C7-84EE-B2764798B903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{585D937E-88FE-48C7-84EE-B2764798B903}.Debug|Any CPU.Build.0 = Debug|Any CPU
{585D937E-88FE-48C7-84EE-B2764798B903}.Release|Any CPU.ActiveCfg = Release|Any CPU
{585D937E-88FE-48C7-84EE-B2764798B903}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 9432ec1

Please sign in to comment.