[Mono-osx] typeof returns MonoType instead of Type for object mocked with FakeItEasy

tron_thomas tron.thomas at frontier.com
Sat Aug 2 23:54:00 UTC 2014


I am using Xamarin Studio to develop a simple console application using TDD
with FakeItEasy. I am trying to write a test that is similar to the
following code:

using System;
using NUnit.Framework;
using FakeItEasy;

namespace TypeProblem
{
	public class SomeObject
	{
		internal SomeObject(Type someType)
		{
		}
	}

	[TestFixture]
	public class TypeTest
	{
		[Test]
		public void TestType()
		{
			SomeObject someObject = A.Fake<SomeObject>(options =>
options.WithArgumentsForConstructor(new object[] { typeof(Object) }));
		}
	}

	class MainClass
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("Hello World!");
		}
	}
}

When I go to run the test I get this error:

FakeItEasy.Core.FakeCreationException:
 Failed to create fake of type “TypeProblem.SomeObject” with the specified
arguments for the constructor:
  No constructor matches the passed arguments for constructor.
  An exception was caught during this call. Its message was:
  Can not instantiate proxy of class: TypeProblem.SomeObject.
  Could not find a constructor that would match the given arguments:
  System.MonoType

I don't understand why it wants to use System.MonoType as the constructor
argument type instead of System.Type, which is the actual type needed for
the constructor.

How can I successfully create the fake object I need for writing a test?




--
View this message in context: http://mono.1490590.n4.nabble.com/typeof-returns-MonoType-instead-of-Type-for-object-mocked-with-FakeItEasy-tp4663471.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list