Skip to content

Commit

Permalink
Binary data binding (Azure#17728)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft committed Jan 5, 2021
1 parent dbaa81a commit 8ddde06
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ public async Task EventHub_MultipleDispatch()
AssertMultipleDispatchLogs(host);
}

[Test]
public async Task EventHub_MultipleDispatch_BinaryData()
{
var (jobHost, host) = BuildHost<EventHubTestMultipleDispatchJobsBinaryData>();
using (jobHost)
{
int numEvents = 5;
await jobHost.CallAsync(nameof(EventHubTestMultipleDispatchJobsBinaryData.SendEvents_TestHub), new { numEvents = numEvents, input = _testId });

bool result = _eventWait.WaitOne(Timeout);
Assert.True(result);
}

AssertMultipleDispatchLogs(host);
}

[Test]
public async Task EventHub_MultipleDispatch_BinaryData()
{
Expand Down Expand Up @@ -493,6 +509,39 @@ public static void ProcessMultipleEventsBinaryData([EventHubTrigger(TestHubName)
}
}

public class EventHubTestMultipleDispatchJobsBinaryData
{
private static int s_eventCount;
private static int s_processedEventCount;
public static void SendEvents_TestHub(int numEvents, string input, [EventHub(TestHubName)] out BinaryData[] events)
{
s_eventCount = numEvents;
events = new BinaryData[numEvents];
for (int i = 0; i < numEvents; i++)
{
events[i] = new BinaryData(input);
}
}

public static void ProcessMultipleEventsBinaryData([EventHubTrigger(TestHubName)] BinaryData[] events,
string[] partitionKeyArray, DateTime[] enqueuedTimeUtcArray, IDictionary<string, object>[] propertiesArray,
IDictionary<string, object>[] systemPropertiesArray)
{
Assert.AreEqual(events.Length, partitionKeyArray.Length);
Assert.AreEqual(events.Length, enqueuedTimeUtcArray.Length);
Assert.AreEqual(events.Length, propertiesArray.Length);
Assert.AreEqual(events.Length, systemPropertiesArray.Length);

s_processedEventCount += events.Length;

// filter for the ID the current test is using
if (events[0].ToString() == _testId && s_processedEventCount == s_eventCount)
{
_eventWait.Set();
}
}
}

public class EventHubPartitionKeyTestJobs
{
// send more events per partition than the EventHubsOptions.MaxBatchSize
Expand Down

0 comments on commit 8ddde06

Please sign in to comment.