Skip to content

Commit c840782

Browse files
committed
Added unit tests for the ViewDataTestPlugin.
1 parent f6979c3 commit c840782

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace MyTested.AspNetCore.Mvc.Test.PluginsTests
2+
{
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Plugins;
5+
using System;
6+
using Xunit;
7+
8+
public class ViewDataTestPluginTests
9+
{
10+
[Fact]
11+
public void ShouldHavePriorityWithDefaultValue()
12+
{
13+
var testPlugin = new ViewDataTestPlugin();
14+
15+
Assert.IsAssignableFrom<IDefaultRegistrationPlugin>(testPlugin);
16+
Assert.NotNull(testPlugin);
17+
Assert.Equal(-1000, testPlugin.Priority);
18+
}
19+
20+
[Fact]
21+
public void ShouldThrowArgumentNullExceptionWithInvalidServiceCollection()
22+
{
23+
var testPlugin = new ViewDataTestPlugin();
24+
25+
Assert.Throws<ArgumentNullException>(() => testPlugin.DefaultServiceRegistrationDelegate(null));
26+
}
27+
28+
[Fact]
29+
public void ShouldInvokeMethodOfTypeVoidWithValidServiceCollection()
30+
{
31+
var testPlugin = new ViewDataTestPlugin();
32+
var serviceCollection = new ServiceCollection();
33+
34+
testPlugin.DefaultServiceRegistrationDelegate(serviceCollection);
35+
36+
var methodReturnType = testPlugin.DefaultServiceRegistrationDelegate.Method.ReturnType.Name;
37+
38+
Assert.True(methodReturnType == "Void");
39+
Assert.True(serviceCollection.Count == 126);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)