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.IsNotNull(resolved, "The proxy object resolved should not be null.");
     ((IServiceContract)resolved).MethodToProxy();
     Assert.IsTrue(implementation.ProxyMethodCalled, "The proxy object should proxy the methods on the implementation.");
 }
 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_NullConstructorString()
 {
     var provider = new MultitenantServiceImplementationDataProvider();
     Assert.Throws<ArgumentNullException>(() => provider.GetServiceImplementationData(null));
 }
 public void GetServiceImplementationData_ConstructorStringDoesNotResolveToType()
 {
     var provider = new MultitenantServiceImplementationDataProvider();
     Assert.Throws<InvalidOperationException>(() => provider.GetServiceImplementationData("This is not a type name."));
 }
 public void GetServiceImplementationData_ConstructorStringDoesNotResolveToServiceContract()
 {
     var provider = new MultitenantServiceImplementationDataProvider();
     Assert.Throws<InvalidOperationException>(() => provider.GetServiceImplementationData(typeof(INotAServiceContract).AssemblyQualifiedName));
 }