Dreamine.FullKit.Tests 1.0.0.0
Dreamine.FullKit.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
로딩중...
검색중...
일치하는것 없음
AutoRegistrationTests.cs
이 파일의 문서화 페이지로 가기
1using System.Reflection;
2using Dreamine.MVVM.Core.AutoRegistration;
3using Dreamine.MVVM.Core.DependencyInjection;
4using Dreamine.MVVM.Interfaces.DependencyInjection;
5
7
16public sealed class AutoRegistrationTests
17{
42 [Theory]
43 [InlineData(typeof(CustomerModel), true)]
44 [InlineData(typeof(CustomerEvent), true)]
45 [InlineData(typeof(CustomerManager), false)]
46 [InlineData(typeof(ExplicitlyRegisteredUtility), true)]
47 [InlineData(typeof(CustomerViewModel), true)]
48 [InlineData(typeof(CustomerService), false)]
49 public void NamingConventionFilter_IdentifiesSupportedTypes(Type type, bool expected)
50 {
51 Assert.Equal(expected, new NamingConventionAutoRegistrationFilter().IsTarget(type));
52 }
53
62 [Fact]
64 {
65 var container = new DreamineContainer();
66 var service = new AutoRegistrationService(
67 new SingleAssemblyScanner(typeof(CustomerModel).Assembly),
68 new NamingConventionAutoRegistrationFilter());
69
70 service.RegisterAll(typeof(CustomerModel).Assembly, container);
71
72 Assert.True(container.IsRegistered(typeof(CustomerModel)));
73 Assert.Same(container.Resolve<CustomerModel>(), container.Resolve<CustomerModel>());
74 Assert.False(container.IsRegistered(typeof(CustomerService)));
75 }
76
85 private sealed class SingleAssemblyScanner : IAssemblyTypeScanner
86 {
95 private readonly Assembly _assembly;
96
113 public SingleAssemblyScanner(Assembly assembly)
114 {
115 _assembly = assembly;
116 }
117
142 public IEnumerable<Assembly> GetCandidateAssemblies(Assembly rootAssembly)
143 {
144 yield return _assembly;
145 }
146
171 public IEnumerable<Type> GetLoadableTypes(Assembly assembly)
172 {
173 return assembly.GetTypes();
174 }
175 }
176
185 public sealed class CustomerModel
186 {
187 }
188
197 public sealed class CustomerEvent
198 {
199 }
200
209 public sealed class CustomerManager
210 {
211 }
212
221 [DreamineRegister]
222 public sealed class ExplicitlyRegisteredUtility
223 {
224 }
225
234 public sealed class CustomerViewModel
235 {
236 }
237
246 public sealed class CustomerService
247 {
248 }
249
258 private sealed class DreamineRegisterAttribute : Attribute
259 {
260 }
261}
void NamingConventionFilter_IdentifiesSupportedTypes(Type type, bool expected)