public void AgentEventRectifierUnsupplyTest() { System.Collections.Generic.Dictionary <System.Type, System.Type> types = new System.Collections.Generic.Dictionary <System.Type, System.Type>(); types.Add(typeof(IType), typeof(CType)); InterfaceProvider ip = new InterfaceProvider(types); TestAgent agent = new TestAgent(); CType cType = new CType(1); object outInstance = null; System.Type outType = null; using (Remote.Client.AgentEventRectifier rectifier = new Remote.Client.AgentEventRectifier(ip.Types, agent)) { rectifier.SupplyEvent += (type, instance) => { }; rectifier.UnsupplyEvent += (type, instance) => { outInstance = instance; outType = type; }; agent.Add(typeof(IType), cType); agent.Remove(typeof(IType), cType); } Assert.Equal(outInstance, cType); Assert.Equal(typeof(IType), outType); }
public void InterfaceProviderTyepsTest() { System.Collections.Generic.Dictionary <System.Type, System.Type> types = new System.Collections.Generic.Dictionary <System.Type, System.Type>(); types.Add(typeof(IType), typeof(CType)); InterfaceProvider ip = new InterfaceProvider(types); System.Type type = ip.Types.First(); Assert.Equal(type, typeof(IType)); }
public AgentCore(IProtocol protocol) { _Protocol = protocol; _Serializer = _Protocol.GetSerialize(); _GhostInterfaceProvider = protocol.GetInterfaceProvider(); _ReturnValueQueue = new ReturnValueQueue(); _ServerProviders = new Dictionary <Type, IProvider>(); _AutoRelease = new AutoRelease(_Requester); }
public static IProtocol CreateProtocol(ISerializer serializer) { IProtocol protocol = NSubstitute.Substitute.For <IProtocol>(); var types = new System.Collections.Generic.Dictionary <System.Type, System.Type>(); types.Add(typeof(IGpiA), typeof(GhostIGpiA)); InterfaceProvider interfaceProvider = new InterfaceProvider(types); protocol.GetInterfaceProvider().Returns(interfaceProvider); protocol.GetSerialize().Returns(serializer); System.Func <IProvider> gpiaProviderProvider = () => new TProvider <IGpiA>(); System.Tuple <System.Type, System.Func <IProvider> >[] typeProviderProvider = new System.Tuple <System.Type, System.Func <IProvider> >[] { new System.Tuple <System.Type, System.Func <IProvider> >(typeof(IGpiA), gpiaProviderProvider) }; protocol.GetMemberMap().Returns(new MemberMap(new System.Reflection.MethodInfo[0], new System.Reflection.EventInfo[0], new System.Reflection.PropertyInfo[0], typeProviderProvider)); return(protocol); }