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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void ThenAnArgumentNullExceptionIsThrown()
        {
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(() => ServiceExtensions.AddService(Mock.Of <IServiceCollection>(), null));

            Assert.AreEqual("declaration", exception.ParamName);
        }
Пример #4
0
        public void ThenAnArgumentNullExceptionIsThrown()
        {
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(() => ServiceExtensions.AddService(null, declaration));

            Assert.AreEqual("services", exception.ParamName);
        }