forked from BAndysc/WoWDatabaseEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleTests.cs
54 lines (48 loc) · 1.35 KB
/
ModuleTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using NUnit.Framework;
using Prism.Ioc;
using Unity;
using WDE.Module;
using WDE.Module.Attributes;
namespace WoWDatabaseEditorCore.Test;
public class ModuleTests
{
[Test]
public void TestModule()
{
var module = new Module();
IUnityContainer unity = new UnityContainer();
var ext = new Prism.Unity.Ioc.UnityContainerExtension(unity);
module.InitializeCore("core");
module.RegisterTypes(ext);
var interfaceA = ext.Resolve<IInterfaceA>();
var interfaceB = ext.Resolve<IInterfaceB>();
Assert.AreEqual(0, interfaceA.A());
Assert.AreEqual(1, interfaceA.A());
Assert.AreEqual(2, interfaceB.B());
Assert.AreEqual(3, interfaceA.A());
Assert.AreSame(interfaceA, interfaceB);
}
internal interface IInterfaceA
{
int A();
}
internal interface IInterfaceB
{
int B();
}
[SingleInstance]
internal class Implementation : IInterfaceA, IInterfaceB
{
private int x;
public int A() => x++;
public int B() => x++;
}
internal class Module : ModuleBase
{
public override void RegisterTypes(IContainerRegistry containerRegistry)
{
base.RegisterTypes(containerRegistry);
RegisterType(typeof(Implementation), containerRegistry, false);
}
}
}