Pregunta

Acabo de escribir algunas pruebas unitarias y para mi horror, falló.

Aquí está mi prueba ...

[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); 
  }
}

me está dando la siguiente excepción: No se puede emitir un objeto de tipo 'Entities.Testing.TempClient' para escribir 'System.String'. ¿Es esto normal? Espero que no. La siguiente prueba funciona correctamente. Supongo que hay un problema al analizar la expresión ... ¿Se solucionará esto?

[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); 
  }
}
¿Fue útil?

Solución

Después de contactar al soporte de Telerik, resultó que no era posible.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top