我有一个看起来像这样的演员:
public class MyActor : Actor, IMyActor
{
public async Task<ICustomerActor> GetCustomer()
{
var customerId = await StateManager.TryGetStateAsync<ActorId>(CustomerIdState);
return customerId.HasValue
? ActorProxy.Create<ICustomerActor>(customerId.Value)
: null;
}
}
我想知道是否有办法测试这种类型的交互。我们使用ServiceFabric.Mocks库来设置在正在运行的服务之外创建演员所需的所有脚手架,但是当它到达ActorProxy.Create<ICustomerActor>(customerId.Value)
线路时,它会引发异常,因为没有任何东西像真正的服务那样真正捆绑在一起。
System.ArgumentException
Failed to determine the current application, please provide application name.
Parameter name: applicationName
at Microsoft.ServiceFabric.Actors.Generator.ActorNameFormat.GetFabricServiceUri(Type actorInterfaceType, String applicationName, String serviceName)
at Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory.CreateActorProxy[TActorInterface](ActorId actorId, String applicationName, String serviceName, String listenerName)
at Microsoft.ServiceFabric.Actors.Client.ActorProxy.Create[TActorInterface](ActorId actorId, String applicationName, String serviceName, String listenerName)