我在Visual Studio Team Services(以前的Visual Studio Online)中进行了自动构建.解决方案正在构建中.如何配置它以便创建Web部署包?
我想使用Autofixture创建FormsAuthenticationTicket的实例(我无法控制,System.Web.Security的一部分)并确保UserData(类型为string)包含有效的XML字符串
var testTicket = fixture.Create<FormsAuthenticationTicket>();
Run Code Online (Sandbox Code Playgroud)
问题是UserData只能在使用以下构造函数实例化对象时设置:
public FormsAuthenticationTicket(int version, string name, DateTime issueDate, DateTime expiration, bool isPersistent, string userData);
Run Code Online (Sandbox Code Playgroud)
其中"userData"是有效的XML字符串.
我可以将此类型配置为使用最贪婪的构造函数,但这并不能解决向userData提供有效XML字符串的问题.
我可以冻结字符串类型以使其始终返回有效的XML字符串,但我也关心我的测试中的其他字符串值.
我想可能的方法是自定义字符串生成的算法...但我没有参数知道何时提供XML字符串.
我正在创建一个可靠,有状态的服务演员.
题:
有没有办法在actor代理创建(ActorProxy.Create())期间传递初始化数据?基本上相当于我的演员的构造函数.
目前的想法:
我可以通过使用负责初始化状态的actor方法调用来跟进代理创建调用来实现这一点.
例如
//Danger, the following calls are not atomic
ITokenManager tokenActor = ActorProxy.Create<IMyActor>(actorId, "AppName");
//Something could happen here and leave my actor in an unknown state
await tokenActor.InitializeAsync(desiredInitialState);
Run Code Online (Sandbox Code Playgroud)
我对这种方法的关注:
在演员中注册计时器的签名是:
IActorTimer RegisterTimer(Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period);
Run Code Online (Sandbox Code Playgroud)
题:
为什么asynCallback期望将状态作为object类型的函数参数接收.毕竟,我的回调已经是Actor的一部分,可以直接访问状态.因此,对象作为参数的要求似乎是多余的.
目前的想法
一个可能的原因是,这允许我们将actor状态提供给不属于actor的回调(这甚至是可能的).这是唯一的原因吗?或者,在从定时器激活方法处理状态时,我是否应该考虑其他因素?