Пример #1
0
        public void ShouldAssignDefaultServiceWhenMultipleImplementationsOfTheSameInterfaceExist()
        {
            var loader = new ServiceLoader();
            IEnumerable<IServiceInfo> list = loader.Load(hostAssembly);

            var serviceResolver = new DefaultServiceResolver();
            IServiceInfo serviceInfo = serviceResolver.GetDefaultService(typeof(IVehicle), list);

            Assert.AreEqual("Vehicle", serviceInfo.ServiceName);
            Assert.AreEqual(typeof(IVehicle), serviceInfo.ServiceType);
            Assert.AreEqual(typeof(Vehicle), serviceInfo.ImplementingType);
        }
Пример #2
0
        public void ShouldLoadTypeImplementationsHavingTheirTypeNameAsTheServiceName()
        {
            var loader = new ServiceLoader();
            IEnumerable<IServiceInfo> list = loader.Load(hostAssembly);

            var expectedService = new ServiceInfo(typeof(IPerson), typeof(Person), "Person");
            var serviceList = new List<IServiceInfo>(list);
            Assert.IsTrue(serviceList.Contains(expectedService));
        }
Пример #3
0
        public void ShouldNotHaveDefaultServicesWhenLoadingTypesFromAssembly()
        {
            var loader = new ServiceLoader();
            IEnumerable<IServiceInfo> list = loader.Load(hostAssembly);

            var items = new List<IServiceInfo>(list);
            Assert.IsTrue(items.Count > 0);
            foreach (var service in list)
            {
                var serviceName = service.ServiceName;
                Assert.IsFalse(string.IsNullOrEmpty(serviceName));
            }
        }
Пример #4
0
        public void ShouldLoadImplementationMapIntoMemory()
        {
            var loader = new ServiceLoader();
            IEnumerable<IServiceInfo> list = loader.Load(hostAssembly);
            Assert.IsNotNull(list);

            var items = new List<IServiceInfo>(list);
            Assert.IsTrue(items.Count > 0);
        }