示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }