Пример #1
0
        public void InstanceProviderIsSetForImplementedContracts()
        {
            var sut = new DryIocServiceBehavior(_containerMock.Object);
            var serviceEndpoints = new[] {
                new ServiceEndpoint(new ContractDescription(nameof(String))
                {
                    ContractType = typeof(string)
                })
            };

            var serviceDescription = new ServiceDescription(serviceEndpoints)
            {
                ServiceType = typeof(string)
            };

            var channelListener   = new Mock <IChannelListener>();
            var channelDispatcher = CreateChannelDispatchers();

            _serviceHostMock.Object.ChannelDispatchers.Add(channelDispatcher);

            sut.ApplyDispatchBehavior(serviceDescription, _serviceHostMock.Object);

            Assert.Equal(3, channelDispatcher.Endpoints.Count);
            Assert.True(channelDispatcher.Endpoints.Single(e => e.ContractName == nameof(String)).DispatchRuntime.InstanceProvider.GetType() == typeof(DryIocInstanceProvider));
            Assert.True(channelDispatcher.Endpoints.Where(e => e.ContractName != nameof(String)).Select(e => e.DispatchRuntime).All(dr => dr.InstanceProvider == null));
        }
Пример #2
0
        public void ApplyDispatchBehaviorThrowsNullArgumentExceptionForNullArguments()
        {
            var sut = new DryIocServiceBehavior(_containerMock.Object);
            var serviceDescription = new ServiceDescription();

            Assert.Throws <ArgumentNullException>("serviceDescription", () => sut.ApplyDispatchBehavior(null, _serviceHostMock.Object));
            Assert.Throws <ArgumentNullException>("serviceHostBase", () => sut.ApplyDispatchBehavior(serviceDescription, null));
        }