Estoy tratando de burlarme de la clase SearchResultCollection. Sin embargo, cuando intento de interceptar una llamada al captador PropertiesLoaded, mi prueba se emite una excepción:Moq C# construido en la clase
System.NotSupportedException: Invalid setup on a non-virtual (overridable in VB) member: x => x.PropertiesLoaded
Mi Código:
Mock<SearchResultCollection> searchResultMock = new Mock<SearchResultCollection>();
// Set up collection that will be returned
string[] tempData = { "one", "two" };
searchResultMock.SetupGet(x => x.PropertiesLoaded).Returns(tempData);
Alguien ha burlado con éxito una clase como esta? La propiedad en cuestión solo tiene un getter y no es virtual.
//
// Summary:
// Gets the System.DirectoryServices.DirectorySearcher properties that were
// specified before the search was executed.
//
// Returns:
// An array of type System.String that contains the properties that were specified
// in the System.DirectoryServices.DirectorySearcher.PropertiesToLoad property
// collection before the search was executed.
public string[] PropertiesLoaded { get; }
posible duplicado de [? Por qué no puedo burlarse MouseButtonEventArgs.GetPosition() con Moq] (http://stackoverflow.com/questions/1918208/why-cant-i-mock-mousebuttoneventargs-getposition-with-moq) – TrueWill