我有两种扩展方法:
public static IPropertyAssertions<T> ShouldHave<T>(this T subject)
{
return new PropertyAssertions<T>(subject);
}
public static IPropertyAssertions<T> ShouldHave<T>(this IEnumerable<T> subject)
{
return new CollectionPropertyAssertions<T>(subject);
}
Run Code Online (Sandbox Code Playgroud)
现在我写一些使用它的代码:
List<Customer> collection2 = new List<Customer>();
collection2.ShouldHave(); //first overload is chosen
IEnumerable<Customer> collection3 = new List<Customer>();
collection3.ShouldHave(); //second overload is chosen
Run Code Online (Sandbox Code Playgroud)
仅当我明确指定IEnumerable类型时才选择第二个重载.有没有办法在两种情况下都选择第二次过载?
我想我完全理解SpecFlow背后的概念和想法,但即使阅读了Secret Ninja Cucumber Scrolls,The Cucumber Book,并且经历了各种论坛,我仍然不确定可重用性的途径.
我们的方案已经符合各种指南
我们的步骤必须遵守以下准则(一些特定于SpecFlow):
但即使我们使用正则表达式占位符,我们仍然会得到相同步骤的大量变体.特别是如果某些事情不重要,你就不应该提到这些变化的规则.是的,在内部这些步骤重复使用,但不在场景中.
考虑例如以下场景:
Feature: Signing where both persons are physically available
@Smoke
Scenario: Show remaining time to sign based on previous signature
Given a draft proposal
And the first signature has been set
When I try to set …Run Code Online (Sandbox Code Playgroud) 我担心我已经知道了答案,但我希望有人可以提供以前没有找到的替代解决方案.一如既往地根据有效聚合设计做DDD 比我想象的要困难,但这是我的情景.
因此,理论上,当一个请求(它是一个ASP.NET MVC应用程序)正在执行上面提到的场景时,另一个请求可能会向用户授予相同的RoleGroup.如果在上述域事件处理程序扫描与该RoleGroup相关的用户之后发生这种情况,则该请求将完成.此时,您有一个已删除的RoleGroup(尽管不是物理上的)和仍保留该RoleGroup标识的User.
你怎么防止这种情况?我们目前正在考虑使用户的身份被授予该RoleGroup AR的特定RoleGroup部分,因此删除RoleGroup并将其授予用户将导致乐观的并发冲突.但不知何故,这不是正确的解决方案.