Exemplo n.º 1
0
Arquivo: Mock.cs Projeto: lxf/moq4
 private static object GetInitialValue(IDefaultValueProvider valueProvider, Stack <Type> mockedTypesStack, PropertyInfo property)
 {
     if (mockedTypesStack.Contains(property.PropertyType))
     {
         // to deal with loops in the property graph
         valueProvider = new EmptyDefaultValueProvider();
     }
     else
     {
         // to make sure that properties of types that don't impelemt ISerializable properly (Castle throws ArgumentException)
         // are mocked with default value instead.
         // It will only result in exception if the properties are accessed.
         valueProvider = new SerializableTypesValueProvider(valueProvider);
     }
     return(valueProvider.ProvideDefault(property.GetGetMethod()));
 }