public void Setup() { ServiceCollection subject = new ServiceCollection(); ServiceDeclaration singletonOneDeclaration = new ServiceDeclaration(typeof(TestImplementation), typeof(TestImplementation), ServiceScope.Singleton); ServiceDeclaration singletonTwoDeclaration = new ServiceDeclaration(typeof(TestImplementation), typeof(TestImplementation), ServiceScope.Singleton); ServiceExtensions.AddService(subject, singletonOneDeclaration); ServiceExtensions.AddService(subject, singletonTwoDeclaration); result = subject.BuildServiceProvider(); }
public void Setup() { IEnumerable <ServiceDescriptor> serviceDescriptors = new ServiceDescriptor[0]; services = new Mock <IServiceCollection>(); services .Setup(instance => instance.GetEnumerator()) .Returns(serviceDescriptors.GetEnumerator()); ServiceDeclaration declaration = new ServiceDeclaration(typeof(ITransientInterface), typeof(TestImplementation), declartionScope); ServiceExtensions.AddService(services.Object, declaration); }
public void ThenAnArgumentNullExceptionIsThrown() { ArgumentNullException exception = Assert.Throws <ArgumentNullException>(() => ServiceExtensions.AddService(Mock.Of <IServiceCollection>(), null)); Assert.AreEqual("declaration", exception.ParamName); }
public void ThenAnArgumentNullExceptionIsThrown() { ArgumentNullException exception = Assert.Throws <ArgumentNullException>(() => ServiceExtensions.AddService(null, declaration)); Assert.AreEqual("services", exception.ParamName); }