Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unit test and rename FirstPlugin #335

Merged
merged 2 commits into from
Oct 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 6 additions & 43 deletions test/Microsoft.Azure.EventHubs.Tests/Client/PluginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class PluginTests
Task Registering_plugin_multiple_times_should_throw()
{
this.EventHubClient = EventHubClient.CreateFromConnectionString(TestUtility.EventHubsConnectionString);
var firstPlugin = new FirstSendPlugin();
var secondPlugin = new FirstSendPlugin();
var firstPlugin = new SamplePlugin();
var secondPlugin = new SamplePlugin();

this.EventHubClient.RegisterPlugin(firstPlugin);
Assert.Throws<ArgumentException>(() => EventHubClient.RegisterPlugin(secondPlugin));
Expand All @@ -31,7 +31,7 @@ Task Registering_plugin_multiple_times_should_throw()
Task Unregistering_plugin_should_complete_with_plugin_set()
{
this.EventHubClient = EventHubClient.CreateFromConnectionString(TestUtility.EventHubsConnectionString);
var firstPlugin = new FirstSendPlugin();
var firstPlugin = new SamplePlugin();

this.EventHubClient.RegisterPlugin(firstPlugin);
this.EventHubClient.UnregisterPlugin(firstPlugin.Name);
Expand All @@ -47,31 +47,6 @@ Task Unregistering_plugin_should_complete_without_plugin_set()
return this.EventHubClient.CloseAsync();
}

[Fact]
[DisplayTestMethodName]
async Task Multiple_plugins_should_run_in_order()
{
this.EventHubClient = EventHubClient.CreateFromConnectionString(TestUtility.EventHubsConnectionString);

try
{
var firstPlugin = new FirstSendPlugin();
var secondPlugin = new SecondSendPlugin();

this.EventHubClient.RegisterPlugin(firstPlugin);
this.EventHubClient.RegisterPlugin(secondPlugin);

var testEvent = new EventData(Encoding.UTF8.GetBytes("Test message"));
await this.EventHubClient.SendAsync(testEvent);

// BeforeEventSend for Plugin2 should break is 1 was not called
}
finally
{
await this.EventHubClient.CloseAsync();
}
}

[Fact]
[DisplayTestMethodName]
async Task Plugin_without_ShouldContinueOnException_should_throw()
Expand Down Expand Up @@ -112,9 +87,9 @@ async Task Plugin_with_ShouldContinueOnException_should_continue()
}
}

internal class FirstSendPlugin : EventHubsPlugin
internal class SamplePlugin : EventHubsPlugin
{
public override string Name => nameof(FirstSendPlugin);
public override string Name => nameof(SamplePlugin);

public override Task<EventData> BeforeEventSend(EventData eventData)
{
Expand All @@ -123,18 +98,6 @@ public override Task<EventData> BeforeEventSend(EventData eventData)
}
}

internal class SecondSendPlugin : EventHubsPlugin
{
public override string Name => nameof(SecondSendPlugin);

public override Task<EventData> BeforeEventSend(EventData eventData)
{
Assert.True((bool)eventData.Properties["FirstSendPlugin"]);
eventData.Properties.Add("SecondSendPlugin", true);
return Task.FromResult(eventData);
}
}

internal class ExceptionPlugin : EventHubsPlugin
{
public override string Name => nameof(ExceptionPlugin);
Expand All @@ -156,4 +119,4 @@ public override Task<EventData> BeforeEventSend(EventData eventData)
throw new NotImplementedException();
}
}
}
}