public void TestMethodSpecialInterfaceClassMapping() { var t = typeof(IOCTalk.Test.Common.Service.MyTestService); DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSessionService <IMyTestService>(); hostContainer.RegisterRemoteService <IMyRemoteTestService>(); hostContainer.RegisterExposedSubInterfaceForType <IMapTestMainInterface, MapTestMain>(); hostContainer.RegisterExposedSubInterfaceForType <IMapTestDerivedInterface, MapTestDerived>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); Common.Session.Session session = new Common.Session.Session(dummyComm, 123, "Unit Test Dummy Session"); var result = hostContainer.CreateSessionContractInstance(session); Type resultTypeMain = hostContainer.GetInterfaceImplementationType(typeof(IMapTestMainInterface).FullName); Assert.Equal(typeof(MapTestMain), resultTypeMain); Type resultTypeDerived = hostContainer.GetInterfaceImplementationType(typeof(IMapTestDerivedInterface).FullName); Assert.Equal(typeof(MapTestDerived), resultTypeDerived); }
public void TestMethodSubscribeSessionStateChange() { AdvancedImportService.CreatedCount = 0; DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); //hostContainer.RegisterLocalSessionService<IAdvancedSessionStateChangeService>(); hostContainer.RegisterLocalSharedService <IAdvancedSessionStateChangeService>(); hostContainer.RegisterRemoteService <IMyTestService>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); Common.Session.Session session = new Common.Session.Session(dummyComm, 123, "Unit Test Dummy Session"); var contract = hostContainer.CreateSessionContractInstance(session); dummyComm.RaiseSessionCreated(session, contract); Assert.Equal(1, AdvancedImportService.CreatedCount); dummyComm.RaiseSessionTerminated(session, contract); Assert.Equal(0, AdvancedImportService.CreatedCount); }
public void TestMethodBuildDataTransferInterfaceImplementation() { var t = typeof(IOCTalk.Test.Common.Service.MyTestService); DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSessionService <IMyTestService>(); hostContainer.RegisterRemoteService <IMyRemoteTestService>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); Common.Session.Session session = new Common.Session.Session(dummyComm, 123, "Unit Test Dummy Session"); var result = hostContainer.CreateSessionContractInstance(session); Type resultType = hostContainer.GetInterfaceImplementationType(typeof(IDataTransferTest).FullName); }
public void TestMethodMutualLocalImports() { MyLocalService.InstanceCount = 0; OtherLocalService.InstanceCount = 0; DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSessionService <IMyLocalService>(); hostContainer.RegisterLocalSessionService <IOtherLocalService>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); Common.Session.Session session = new Common.Session.Session(dummyComm, 123, "Unit Test Dummy Session"); var result = hostContainer.CreateSessionContractInstance(session); Assert.Equal(1, MyLocalService.InstanceCount); Assert.Equal(1, OtherLocalService.InstanceCount); }
public void TestMethodInitCompositionContainer() { var t = typeof(IOCTalk.Test.Common.Service.MyTestService); DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSessionService <IMyTestService>(); hostContainer.RegisterRemoteService <IMyRemoteTestService>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); Common.Session.Session session = new Common.Session.Session(dummyComm, 123, "Unit Test Dummy Session"); SessionContract contract = (SessionContract)hostContainer.CreateSessionContractInstance(session); Assert.Equal(contract.Session, session); object proxyTypeObj = hostContainer.GetInterfaceImplementationInstance(session, typeof(IMyRemoteTestService).FullName); Assert.IsAssignableFrom <IMyRemoteTestService>(proxyTypeObj); }