我刚刚写了一些单元测试,令我感到恐惧的是它失败了。
这是我的测试...
[TestMethod]
public void FetchWithMoreThanOneConditionUsingKnownTypes()
{
using (var scope = EntityObjectScopeProvider.GetNewObjectScope())
{
var temp = new TempClient() { FirstName = "Rohan", Surname = "West" };
var entity = scope.Extent<ClientEntity>().Where(c => temp.FirstName == c.FirstName && temp.Surname == c.Surname).FirstOrDefault();
Assert.IsNotNull(entity);
Assert.AreEqual(entity.FirstName, temp.FirstName);
Assert.AreEqual(entity.Surname, temp.Surname);
}
}
它给了我以下异常,无法将类型为'Entities.Testing.TempClient'的对象强制转换为'System.String'。这是正常的,我希望不是,以下测试正常。我猜解析表达式时会出现问题...这会被解决吗?
[TestMethod]
public void FetchWithMoreThanOneConditionUsingTempVariables()
{
using (var scope = EntityObjectScopeProvider.GetNewObjectScope())
{
var temp = new TempClient(){ FirstName = "Rohan", Surname = "West" };
string firstname = temp.FirstName;
string surname = temp.Surname;
var entity = scope.Extent<ClientEntity>().Where(c => c.FirstName == firstname && c.Surname == surname).FirstOrDefault();
Assert.IsNotNull(entity);
Assert.AreEqual(entity.FirstName, temp.FirstName);
Assert.AreEqual(entity.Surname, temp.Surname);
}
}
答案 0 :(得分:1)
在联系Telerik支持后,结果证明不可能。