Skip to content

Commit

Permalink
Remove unit test and rename FirstPlugin (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Revoledo authored and serkantkaraca committed Oct 18, 2018
1 parent cb3082e commit 13c0e83
Showing 1 changed file with 6 additions and 43 deletions.
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();
}
}
}
}

0 comments on commit 13c0e83

Please sign in to comment.