private void TestAdvancedProxyImplementation() { try { Type result = TypeService.BuildProxyImplementation(typeof(IPerformanceMonitorService)); DummyCommunicationService dummyCommService = new DummyCommunicationService(); var constructorParams = new object[2]; constructorParams[0] = dummyCommService; IPerformanceMonitorService instance = (IPerformanceMonitorService)Activator.CreateInstance(result, constructorParams); TimeSpan timeSpan = new TimeSpan(23532534); List <string> testColl = new List <string>(); testColl.Add("item 1"); string testOutput; instance.SubscribeCpuUsageNotification(timeSpan, out testOutput, testColl); } catch (Exception ex) { // because of buggy unit test environment throw; } }
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 CircularDependencyRegognitionTest() { DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSharedService <ICircularDependencyTest1>(); hostContainer.RegisterLocalSharedServices <ICircularDependencyTest2>(); hostContainer.AddReferencedAssemblies(); Assert.Throws <CircularServiceReferenceException>(() => hostContainer.InitGenericCommunication(dummyComm)); }
public void TestMethodImplementationMapping2() { DummyCommunicationService dummyComm = new DummyCommunicationService(); LocalShareContext localShareContext = new LocalShareContext(); localShareContext.RegisterLocalSharedService <IMyLocalService, MyLocalService>(); localShareContext.Init(); var myService = localShareContext.GetExport <IMyLocalService>(); Assert.Equal(typeof(MyLocalService), myService.GetType()); }
public void TestMethodMultipleLocalImports() { MyLocalService.InstanceCount = 0; OtherLocalService.InstanceCount = 0; DummyCommunicationService dummyComm = new DummyCommunicationService(); TalkCompositionHost hostContainer = new TalkCompositionHost(); hostContainer.RegisterLocalSharedService <IMultipleLocalImportsService>(); hostContainer.RegisterLocalSharedServices <IMultipleImplementation>(); hostContainer.AddReferencedAssemblies(); hostContainer.InitGenericCommunication(dummyComm); var multiImportsService = hostContainer.GetExport <IMultipleLocalImportsService>(); Assert.Equal(2, multiImportsService.LocalImplementations.Length); }
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); }
private void TestAdvancedProxyImplementationOutParams() { Type result = TypeService.BuildProxyImplementation(typeof(ITestServiceSpecialOutPrams)); DummyCommunicationService dummyCommService = new DummyCommunicationService(); var constructorParams = new object[2]; constructorParams[0] = dummyCommService; ITestServiceSpecialOutPrams instance = (ITestServiceSpecialOutPrams)Activator.CreateInstance(result, constructorParams); //int? nullableInt; //instance.GetData(out nullableInt); var invokeMethod = new InvokeMethodInfo(typeof(ITestServiceSpecialOutPrams), nameof(ITestServiceSpecialOutPrams.GetData)); var invokeMethodDeserialize = new InvokeMethodInfo(invokeMethod.InterfaceMethod.DeclaringType, invokeMethod.QualifiedMethodName); Assert.NotNull(invokeMethodDeserialize); }
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); }