Fixing eventhub trigger scenario (#400)
Added eventHub handling scenario in AttributeExtensions
This commit is contained in:
Родитель
3bdbccd0fc
Коммит
e91c1f06d0
|
@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Functions
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Functions.MSBuild", "src\Microsoft.NET.Sdk.Functions.MSBuild\Microsoft.NET.Sdk.Functions.MSBuild.csproj", "{1DB38EB5-DBA9-4678-BB99-2BCD1255DDBE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Functions.Generator.V1.Tests", "test\Microsoft.NET.Sdk.Functions.Generator.V1.Tests\Microsoft.NET.Sdk.Functions.Generator.V1.Tests.csproj", "{102600C1-C3BB-4EBF-8513-3CBD72716C10}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -57,6 +59,10 @@ Global
|
|||
{1DB38EB5-DBA9-4678-BB99-2BCD1255DDBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1DB38EB5-DBA9-4678-BB99-2BCD1255DDBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1DB38EB5-DBA9-4678-BB99-2BCD1255DDBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{102600C1-C3BB-4EBF-8513-3CBD72716C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{102600C1-C3BB-4EBF-8513-3CBD72716C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{102600C1-C3BB-4EBF-8513-3CBD72716C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{102600C1-C3BB-4EBF-8513-3CBD72716C10}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -68,6 +74,7 @@ Global
|
|||
{14DF7D60-3AE6-4A5C-A2FF-BE49720DDFEC} = {14D6456E-2F9D-4483-A378-03701A6EB12D}
|
||||
{B80DA350-8A69-4CD2-9E60-01C51B5A8633} = {9B6D0171-3FFD-4892-B407-B633CA4E6712}
|
||||
{1DB38EB5-DBA9-4678-BB99-2BCD1255DDBE} = {14D6456E-2F9D-4483-A378-03701A6EB12D}
|
||||
{102600C1-C3BB-4EBF-8513-3CBD72716C10} = {9B6D0171-3FFD-4892-B407-B633CA4E6712}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DA731A15-774F-46C2-B8DF-298F828DCC2A}
|
||||
|
|
|
@ -202,6 +202,14 @@ namespace MakeFunctionJson
|
|||
return "path";
|
||||
}
|
||||
}
|
||||
else if (attributeName == "EventHubTriggerAttribute" &&
|
||||
attribute.GetType().Assembly.GetName().Version.Major == 2)
|
||||
{
|
||||
if (propertyName == "EventHubName")
|
||||
{
|
||||
return "path";
|
||||
}
|
||||
}
|
||||
else if (attributeName == "ServiceBusTriggerAttribute")
|
||||
{
|
||||
if (propertyName == "Access")
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
#if RELESE_BUILD
|
||||
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Functions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Functions.Test.V1, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d992c94d1071c5467ec320753f4a3cd4e3968a8d16944c09b12baeddee07f0c02c87552de2fe4bf62c35e95449f9a2b3a3930701029981b0dee4dbea68321a19a96289c05a4be24713e1447dd803be701582e6fe6ad53190f51c7200128eb663a81737f32cde60d114a1387e525618e16968c42efa9b3939e6e19806ca230ed1")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
|
||||
#else
|
||||
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Functions.Test")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Functions.Test.V1")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
#endif
|
|
@ -41,15 +41,15 @@ namespace Microsoft.NET.Sdk.Functions.Test
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MyHttpTrigger", "httpTrigger", "request")]
|
||||
[InlineData("MyBlobTrigger", "blobTrigger", "blobContent")]
|
||||
[InlineData("MyQueueTrigger", "queueTrigger", "queue")]
|
||||
[InlineData("MyEventHubTrigger", "eventHubTrigger", "message")]
|
||||
[InlineData("MyTimerTrigger", "timerTrigger", "timer")]
|
||||
[InlineData("MyServiceBusTrigger", "serviceBusTrigger", "message")]
|
||||
[InlineData("MyManualTrigger", "manualTrigger", "input")]
|
||||
[InlineData("MyManualTriggerWithoutParameters", "manualTrigger", null)]
|
||||
public void FunctionMethodsAreExported(string functionName, string type, string parameterName)
|
||||
[InlineData("MyHttpTrigger", "httpTrigger", "request", "authLevel", "function")]
|
||||
[InlineData("MyBlobTrigger", "blobTrigger", "blobContent", "path", "blob.txt")]
|
||||
[InlineData("MyQueueTrigger", "queueTrigger", "queue", "queueName", "queue")]
|
||||
[InlineData("MyTimerTrigger", "timerTrigger", "timer", "schedule", "00:30:00")]
|
||||
[InlineData("MyServiceBusTrigger", "serviceBusTrigger", "message", "queueName", "queue")]
|
||||
[InlineData("MyManualTrigger", "manualTrigger", "input", null, null)]
|
||||
[InlineData("MyManualTriggerWithoutParameters", "manualTrigger", null, null, null)]
|
||||
[InlineData("MyEventHubTrigger", "eventHubTrigger", "message", "eventHubName", "hub")]
|
||||
public void FunctionMethodsAreExported(string functionName, string type, string parameterName, string bindingName, string bindingValue)
|
||||
{
|
||||
var logger = new RecorderLogger();
|
||||
var converter = new FunctionJsonConverter(logger, ".", ".", functionsInDependencies: false);
|
||||
|
@ -58,6 +58,10 @@ namespace Microsoft.NET.Sdk.Functions.Test
|
|||
var binding = schema.Bindings.Single();
|
||||
binding.Value<string>("type").Should().Be(type);
|
||||
binding.Value<string>("name").Should().Be(parameterName);
|
||||
if (bindingName != null)
|
||||
{
|
||||
binding.Value<string>(bindingName).Should().Be(bindingValue);
|
||||
}
|
||||
logger.Errors.Should().BeEmpty();
|
||||
logger.Warnings.Should().BeEmpty();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using FluentAssertions;
|
||||
using MakeFunctionJson;
|
||||
using Microsoft.Azure.WebJobs;
|
||||
using Microsoft.Azure.WebJobs.ServiceBus;
|
||||
using Microsoft.ServiceBus.Messaging;
|
||||
using Microsoft.WindowsAzure.Storage.Queue;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.NET.Sdk.Functions.Test.V1
|
||||
{
|
||||
public class FunctionJsonConverterTests
|
||||
{
|
||||
public class FunctionsClass
|
||||
{
|
||||
[FunctionName("MyHttpTrigger")]
|
||||
public static void Run1([HttpTrigger] HttpRequestMessage request) { }
|
||||
|
||||
[FunctionName("MyBlobTrigger")]
|
||||
public static void Run2([BlobTrigger("blob.txt")] string blobContent) { }
|
||||
|
||||
[FunctionName("MyQueueTrigger")]
|
||||
public static void Run3([QueueTrigger("queue")] CloudQueue queue) { }
|
||||
|
||||
[FunctionName("MyEventHubTrigger")]
|
||||
public static void Run4([EventHubTrigger("hub")] EventData message) { }
|
||||
|
||||
[FunctionName("MyTimerTrigger")]
|
||||
public static void Run5([TimerTrigger("00:30:00")] TimerInfo timer) { }
|
||||
|
||||
[FunctionName("MyServiceBusTrigger")]
|
||||
public static void Run6([ServiceBusTrigger("queue")] string message) { }
|
||||
|
||||
[FunctionName("MyManualTrigger"), NoAutomaticTrigger]
|
||||
public static void Run7(string input) { }
|
||||
|
||||
[FunctionName("MyManualTriggerWithoutParameters"), NoAutomaticTrigger]
|
||||
public static void Run8() { }
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MyHttpTrigger", "httpTrigger", "request", "authLevel", "function")]
|
||||
[InlineData("MyBlobTrigger", "blobTrigger", "blobContent", "path", "blob.txt")]
|
||||
[InlineData("MyQueueTrigger", "queueTrigger", "queue", "queueName", "queue")]
|
||||
[InlineData("MyTimerTrigger", "timerTrigger", "timer", "schedule", "00:30:00")]
|
||||
[InlineData("MyServiceBusTrigger", "serviceBusTrigger", "message", "accessRights", "manage")]
|
||||
[InlineData("MyManualTrigger", "manualTrigger", "input", null, null)]
|
||||
[InlineData("MyManualTriggerWithoutParameters", "manualTrigger", null, null, null)]
|
||||
[InlineData("MyEventHubTrigger", "eventHubTrigger", "message", "path", "hub")]
|
||||
public void FunctionMethodsAreExported(string functionName, string type, string parameterName, string bindingName, string bindingValue)
|
||||
{
|
||||
var logger = new RecorderLogger();
|
||||
var converter = new FunctionJsonConverter(logger, ".", ".", functionsInDependencies: false);
|
||||
var functions = converter.GenerateFunctions(new[] { TestUtility.GetTypeDefinition(typeof(FunctionsClass)) });
|
||||
var schema = functions.Single(e => Path.GetFileName(e.Value.outputFile.DirectoryName) == functionName).Value.schema;
|
||||
var binding = schema.Bindings.Single();
|
||||
binding.Value<string>("type").Should().Be(type);
|
||||
binding.Value<string>("name").Should().Be(parameterName);
|
||||
if(bindingName != null)
|
||||
{
|
||||
binding.Value<string>(bindingName).Should().Be(bindingValue);
|
||||
}
|
||||
logger.Errors.Should().BeEmpty();
|
||||
logger.Warnings.Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>PublicKey.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>true</DelaySign>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
<RootNamespace>Microsoft.NET.Sdk.Functions.Test.V1</RootNamespace>
|
||||
<AssemblyName>Microsoft.NET.Sdk.Functions.Test.V1</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.2" />
|
||||
<PackageReference Include="Microsoft.Azure.WebJobs" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ApiHub" Version="1.0.0-beta9" />
|
||||
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.2.0" />
|
||||
<PackageReference Include="Mono.Cecil" Version="0.11.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.NET.Sdk.Functions.Generator\Microsoft.NET.Sdk.Functions.Generator.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.NET.Sdk.Functions.Generator.Tests\Microsoft.NET.Sdk.Functions.Generator.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче