Skip to content

Commit 9d3e3d1

Browse files
committed
Move common methods to abstract test class
1 parent b00eaf4 commit 9d3e3d1

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

src/UnityContainerAttributeRegistrationTest/Attribute/RegisterTypeAttributeTest.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace UnityContainerAttributeRegistrationTest.Attribute
1919
{
20-
internal class RegisterTypeAttributeTest
20+
internal class RegisterTypeAttributeTest : TestBase
2121
{
2222
[Test]
2323
[TestCase(typeof(Default),
@@ -100,25 +100,5 @@ public void TestPopulate_WithCustomContainer()
100100

101101
AreSame(container, result);
102102
}
103-
104-
private bool IsUnityContainerRegistration(IContainerRegistration registration)
105-
{
106-
bool registeredType = registration.RegisteredType == typeof(IUnityContainer);
107-
bool mappedToType = registration.MappedToType == typeof(UnityContainer);
108-
109-
return registeredType && mappedToType;
110-
}
111-
112-
private bool IsExpectedRegisteredContainer(IContainerRegistration registration,
113-
Type expectedFrom,
114-
Type expectedTo,
115-
Type expectedTypeLifetimeManagerType)
116-
{
117-
bool registeredType = registration.RegisteredType == expectedFrom;
118-
bool mappedToType = registration.MappedToType == expectedTo;
119-
bool lifetimeManager = registration.LifetimeManager.GetType() == expectedTypeLifetimeManagerType;
120-
121-
return registeredType && mappedToType && lifetimeManager;
122-
}
123103
}
124104
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
using Unity;
4+
5+
6+
namespace UnityContainerAttributeRegistrationTest.Helper
7+
{
8+
public abstract class TestBase
9+
{
10+
protected bool IsUnityContainerRegistration(IContainerRegistration registration)
11+
{
12+
bool registeredType = registration.RegisteredType == typeof(IUnityContainer);
13+
bool mappedToType = registration.MappedToType == typeof(UnityContainer);
14+
15+
return registeredType && mappedToType;
16+
}
17+
18+
protected bool IsExpectedRegisteredContainer(IContainerRegistration registration,
19+
Type expectedFrom,
20+
Type expectedTo,
21+
Type expectedTypeLifetimeManagerType)
22+
{
23+
bool registeredType = registration.RegisteredType == expectedFrom;
24+
bool mappedToType = registration.MappedToType == expectedTo;
25+
bool lifetimeManager = registration.LifetimeManager.GetType() == expectedTypeLifetimeManagerType;
26+
27+
return registeredType && mappedToType && lifetimeManager;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)