public object BeforeSendRequest(ref Message request, IClientChannel channel) { ActorIdHelper.Add(request.Headers, ActorId); ServiceContextHelper.Add(request.Headers, Context); OnAddHeaders(request.Headers); OnSending(request.Headers); return(null); }
object GetInstance(MessageHeaders headers, Type actorType) { ActorId id = ActorIdHelper.Get(headers); ServiceContext context = ServiceContextHelper.Get(headers); ActorService service = (context == null) ? new ActorService(null, ActorTypeInformation.Get(actorType)) : new ActorService(new StatefulServiceContext(context.ServiceName), ActorTypeInformation.Get(actorType)); object instance = Activator.CreateInstance(actorType, service, id); return(instance); }
void MockServiceContext <I>(StatelessService target) { ServiceContext context = new ServiceContext(); if (target == null) { Type serviceType = FabricRuntime.Services.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault(); context.ServiceName = ServiceAddress(serviceType); ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, context); AddStandardContexts(OperationContext.Current.OutgoingMessageHeaders); } else { context.ServiceName = ServiceAddress(target.GetType()); MockMessage(); ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, context); AddStandardContexts(OperationContext.Current.IncomingMessageHeaders); } }
void MockServiceContext <I>(StatelessService target) { ServiceContext context = new ServiceContext(); if (target == null) { Type serviceType = FabricRuntime.Services.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault(); context.ServiceName = ServiceAddress(serviceType); ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, context); } else { context.ServiceName = ServiceAddress(target.GetType()); FieldInfo request = typeof(OperationContext).GetField("request", BindingFlags.NonPublic | BindingFlags.Instance); Message message = Message.CreateMessage(MessageVersion.Soap12, "void"); request.SetValue(OperationContext.Current, message); ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, context); } }
void MockActorContexts <I>(ActorBase target) { ActorId actorId = new ActorId("Test"); if (target == null) { Type actorType = FabricRuntime.Actors.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault(); Uri actorAddress = ServiceAddress(actorType); actorId.ApplicationName = actorAddress.Segments[1].TrimEnd('/'); actorId.ActorInterfaceName = typeof(I).FullName; actorId.ActorServiceName = actorAddress.Segments[2]; ActorIdHelper.Add(OperationContext.Current.OutgoingMessageHeaders, actorId); ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, new ServiceContext { ServiceName = actorAddress }); AddStandardContexts(OperationContext.Current.OutgoingMessageHeaders); } else { Uri actorAddress = ServiceAddress(target.GetType()); actorId.ApplicationName = actorAddress.Segments[1].TrimEnd('/'); actorId.ActorInterfaceName = typeof(I).FullName; actorId.ActorServiceName = actorAddress.Segments[2]; MockMessage(); ActorIdHelper.Add(OperationContext.Current.IncomingMessageHeaders, actorId); ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, new ServiceContext { ServiceName = actorAddress }); AddStandardContexts(OperationContext.Current.IncomingMessageHeaders); } }
public static ITestFrameworkAddin GetAddIn(string addinFile) { return(ServiceContextHelper.GetInstance <ITestFrameworkAddin>(addinFile)); }