public void should_persist_value_to_servicetype_property()
        {
            var instanceProvider =
                new ServiceInstanceProvider(typeof(FakeService));

            instanceProvider.ServiceType.ShouldBeOfType<FakeService>();
        }
        public void TestInitialize()
        {
            Ioc.Container = new DependencyInjectionContainer();

            // Arrange
            Ioc.Container = new DependencyInjectionContainer();
            IServiceLocator serviceLocator = Substitute.For <IServiceLocator>();

            _serviceInstanceProvider = new ServiceInstanceProvider(serviceLocator);
        }
        public void should_query_container_with_service_contract_type()
        {
            var mock = new Mock<IServiceLocator>();
            mock.Setup(m => m.GetInstance(typeof(IFakeService))).Returns(new FakeService());

            ServiceLocator.SetLocatorProvider(() => mock.Object);

            var instanceProvider =
                new ServiceInstanceProvider(typeof(FakeService));

            instanceProvider.GetInstance(null).ShouldBeOfType<FakeService>();
        }
Ejemplo n.º 4
0
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            var instanceProvider = new ServiceInstanceProvider(this);

            foreach (ChannelDispatcher cd in serviceHostBase.ChannelDispatchers)
            {
                foreach (EndpointDispatcher ed in cd.Endpoints)
                {
                    if (!ed.IsSystemEndpoint)
                    {
                        ed.DispatchRuntime.InstanceProvider = instanceProvider;
                    }
                }
            }
        }