public void GetServiceImplementationData_DataReturnedBasedOnProxy()
        {
            var provider = new MultitenantServiceImplementationDataProvider();
            var data     = provider.GetServiceImplementationData(typeof(IServiceContract).AssemblyQualifiedName);

            Assert.Equal(typeof(IServiceContract).AssemblyQualifiedName, data.ConstructorString);
            Assert.Equal(1, data.ServiceTypeToHost.FindInterfaces((f, o) => f == (Type)o, typeof(IServiceContract)).Length);
        }
コード例 #2
0
        public void GetServiceImplementationData_DataReturnedBasedOnProxy()
        {
            var provider = new MultitenantServiceImplementationDataProvider();
            var data     = provider.GetServiceImplementationData(typeof(IServiceContract).AssemblyQualifiedName);

            Assert.AreEqual(typeof(IServiceContract).AssemblyQualifiedName, data.ConstructorString, "The constructor string should be the interface name.");
            Assert.AreEqual(1, data.ServiceTypeToHost.FindInterfaces((f, o) => f == (Type)o, typeof(IServiceContract)).Length, "The service type to host should implement the service interface.");
        }
        public void GetServiceImplementationData_DataResolvesTypeThroughProxy()
        {
            var builder        = new ContainerBuilder();
            var implementation = new ServiceImplementation();

            builder.RegisterInstance(implementation).As <IServiceContract>();
            var container = builder.Build();
            var provider  = new MultitenantServiceImplementationDataProvider();
            var data      = provider.GetServiceImplementationData(typeof(IServiceContract).AssemblyQualifiedName);
            var resolved  = data.ImplementationResolver(container.BeginLifetimeScope());

            Assert.NotNull(resolved);
            ((IServiceContract)resolved).MethodToProxy();
            Assert.True(implementation.ProxyMethodCalled);
        }
        public void GetServiceImplementationData_ConstructorStringDoesNotResolveToType()
        {
            var provider = new MultitenantServiceImplementationDataProvider();

            Assert.Throws <InvalidOperationException>(() => provider.GetServiceImplementationData("This is not a type name."));
        }
        public void GetServiceImplementationData_NullConstructorString()
        {
            var provider = new MultitenantServiceImplementationDataProvider();

            Assert.Throws <ArgumentNullException>(() => provider.GetServiceImplementationData(null));
        }
        public void GetServiceImplementationData_ConstructorStringDoesNotResolveToServiceContract()
        {
            var provider = new MultitenantServiceImplementationDataProvider();

            Assert.Throws <InvalidOperationException>(() => provider.GetServiceImplementationData(typeof(INotAServiceContract).AssemblyQualifiedName));
        }