-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathCastleContainerTests.cs
More file actions
64 lines (52 loc) · 1.8 KB
/
CastleContainerTests.cs
File metadata and controls
64 lines (52 loc) · 1.8 KB
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
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0
using NUnit.Framework;
using System;
using System.Collections.Generic;
namespace Moryx.Container.Tests
{
[TestFixture]
public class CastleContainerTests
{
private CastleContainer _container;
[SetUp]
public void Init()
{
_container = new CastleContainer(new Dictionary<Type, string>());
_container.LoadFromAssembly(GetType().Assembly);
}
[Test]
public void LocalsFound()
{
var local = _container.Resolve<ILocalComponent>();
var localFac = _container.Resolve<ILocalFactory>();
Assert.NotNull(local, "Failed to resolve local component!");
Assert.NotNull(localFac, "Failed to resolve local factory");
}
[Test]
public void DefaultFactory()
{
var fac = _container.Resolve<ILocalFactory>();
var comp = fac.Create();
Assert.AreEqual(typeof(LocalComponent), comp.GetType(), "Factory not working!");
}
[Test]
public void NameBasedFactory()
{
var fac = _container.Resolve<INamedComponentFactory>();
var compA = fac.Create(NamedComponentA.ComponentName);
var compB = fac.Create(NamedComponentB.ComponentName);
Assert.AreEqual(NamedComponentA.ComponentName, compA.GetName(), "Component A not resolved by name!");
Assert.AreEqual(NamedComponentB.ComponentName, compB.GetName(), "Component B not resolved by name!");
}
[Test]
public void SpecificDependencyRegistration()
{
}
[TearDown]
public void Destroy()
{
_container.Destroy();
}
}
}