public void ThrowsNotSupportedExceptionWhenAtLeastOneTypeIsNotRegistered() { var serviceLocator = new ServiceLocator(); serviceLocator.RegisterType<object>(); serviceLocator.RegisterType<ITestInterface1, TestClass1>(); ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => serviceLocator.ResolveAllTypes(typeof(object), typeof(ITestInterface1), typeof(ITestInterface2))); }
public void ReturnsAllTypesWhenAllAreRegistered() { var serviceLocator = new ServiceLocator(); serviceLocator.RegisterInstance(new object()); serviceLocator.RegisterType<ITestInterface1, TestClass1>(); serviceLocator.RegisterType<ITestInterface2, TestClass2>(); var resolvedTypes = serviceLocator.ResolveAllTypes(typeof(object), typeof(ITestInterface1), typeof(ITestInterface2)).ToArray(); Assert.AreEqual(3, resolvedTypes.Length); Assert.AreEqual(typeof(object), resolvedTypes[0].GetType()); Assert.AreEqual(typeof(TestClass1), resolvedTypes[1].GetType()); Assert.AreEqual(typeof(TestClass2), resolvedTypes[2].GetType()); }
public void ThrowsArgumentExceptionForNullOrEmptyTypeArray() { var serviceLocator = new ServiceLocator(); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => serviceLocator.ResolveAllTypes(null)); }