集成测试:
UERDomainService uerDomainService;
[TestInitialize]
public void Setup()
{
uerDomainService = new UERDomainService();
}
[TestMethod]
public void GetUsersWithRoles_GivenRoleID1003_ShouldNotReturnMateerAsSoftDeleted()
{
// blah
Assert.AreEqual(0, thing.Count());
// blah
uerDomainService.DeleteRoleMembership(rm);
}
然后在 DeleteRoleMembership(rm) 这是一个 RIA 服务代码生成方法:
public void DeleteRoleMembership(RoleMembership roleMembership)
{
if ((roleMembership.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(roleMembership, EntityState.Deleted);
}
else
{
this.ObjectContext.RoleMemberships.Attach(roleMembership);
this.ObjectContext.RoleMemberships.DeleteObject(roleMembership);
}
// added to get tests working
ObjectContext.SaveChanges();
}
为什么我必须加入这个才能让我的测试正常工作?
然而,我的 Silverlight 应用程序不需要它来工作。我知道这与 RIA 的保存管道有关。uerDomainService.Submit 方法需要一个ChangeSet。
问题:如何从我的测试中启动 SubmitChanges 管道?