Skip to content

Commit e348617

Browse files
committed
Updated tests
1 parent 56386e4 commit e348617

20 files changed

+218
-42
lines changed

NetCore.AutoRegisterDi.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
EndProject
1616
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly", "TestAssembly\TestAssembly.csproj", "{2B4E7847-FFF8-472A-987D-6808B1DCE56F}"
1717
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestBadAssembly", "TestBadAssembly\TestBadAssembly.csproj", "{0E090B35-D105-49C1-95BE-EDC2655D6399}"
19+
EndProject
1820
Global
1921
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2022
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
3335
{2B4E7847-FFF8-472A-987D-6808B1DCE56F}.Debug|Any CPU.Build.0 = Debug|Any CPU
3436
{2B4E7847-FFF8-472A-987D-6808B1DCE56F}.Release|Any CPU.ActiveCfg = Release|Any CPU
3537
{2B4E7847-FFF8-472A-987D-6808B1DCE56F}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{0E090B35-D105-49C1-95BE-EDC2655D6399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{0E090B35-D105-49C1-95BE-EDC2655D6399}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{0E090B35-D105-49C1-95BE-EDC2655D6399}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{0E090B35-D105-49C1-95BE-EDC2655D6399}.Release|Any CPU.Build.0 = Release|Any CPU
3642
EndGlobalSection
3743
GlobalSection(SolutionProperties) = preSolution
3844
HideSolutionNode = FALSE

NetCore.AutoRegisterDi/Attributes/RegisterAsScopedAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace NetCore.AutoRegisterDi.Attributes
33
using System;
44

55
/// <summary>
6-
/// Attribute for marking classes which need to register with Scope life time
6+
/// Attribute for marking classes which need to register with Scope lifetime
77
/// </summary>
88
[AttributeUsage(AttributeTargets.Class)]
99
public class RegisterAsScopedAttribute : Attribute

NetCore.AutoRegisterDi/Attributes/RegisterAsSingletonAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace NetCore.AutoRegisterDi.Attributes
33
using System;
44

55
/// <summary>
6-
/// Attribute for marking classes which need to register with Singleton life time
6+
/// Attribute for marking classes which need to register with Singleton lifetime
77
/// </summary>
88
[AttributeUsage(AttributeTargets.Class)]
99
public class RegisterAsSingletonAttribute : Attribute

NetCore.AutoRegisterDi/Attributes/RegisterAsTransientAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
namespace NetCore.AutoRegisterDi.Attributes
22
{
33
using System;
4-
using System.Runtime.InteropServices;
54

65
/// <summary>
7-
/// Attribute for marking classes which need to register with Transient life time
6+
/// Attribute for marking classes which need to register with Transient lifetime
87
/// </summary>
98
[AttributeUsage(AttributeTargets.Class)]
109
public class RegisterAsTransientAttribute : Attribute
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace Test.Extensions.AssertExtensions
2+
{
3+
using System;
4+
using Xunit;
5+
6+
/// <summary>
7+
/// Extensions which provide assertions to classes derived from <see cref="Action"/>.
8+
/// </summary>
9+
public static class ActionAssertionsExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the action throws exception.
13+
/// </summary>
14+
/// <param name="action">The action to be tested</param>
15+
/// <exception cref="ThrowsException">Thrown if the action is throw exception</exception>
16+
public static void ShouldThrow<T>(this Action action)
17+
where T : Exception
18+
{
19+
Assert.Throws<T>(action);
20+
}
21+
}
22+
}

Test/LocalIgnoredService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Test
2+
{
3+
using NetCore.AutoRegisterDi.Attributes;
4+
5+
[DoNotAutoRegister]
6+
public class LocalIgnoredService : ILocalService
7+
{
8+
public bool IsPositive(int i)
9+
{
10+
return i > 1;
11+
}
12+
}
13+
}

Test/LocalScopeService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Test
2+
{
3+
using NetCore.AutoRegisterDi.Attributes;
4+
5+
[RegisterAsScoped]
6+
public class LocalScopeService : ILocalService
7+
{
8+
public bool IsPositive(int i)
9+
{
10+
return i > 1;
11+
}
12+
}
13+
}

Test/LocalService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Test
55
{
6+
using NetCore.AutoRegisterDi.Attributes;
7+
8+
[RegisterAsTransient]
69
public class LocalService : ILocalService
710
{
811
public bool IsPositive(int i)

Test/LocalSingletonService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Test
2+
{
3+
using NetCore.AutoRegisterDi.Attributes;
4+
5+
[RegisterAsSingleton]
6+
public class LocalSingletonService : ILocalService
7+
{
8+
public bool IsPositive(int i)
9+
{
10+
return i > 1;
11+
}
12+
}
13+
}

Test/LocalTransientService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Test
2+
{
3+
using NetCore.AutoRegisterDi.Attributes;
4+
5+
[RegisterAsTransient]
6+
public class LocalTransientService : ILocalService
7+
{
8+
public bool IsPositive(int i)
9+
{
10+
return i > 1;
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)