I get an exception
The type initializer for "Moq.Mock`1" threw an exception.
using Moq 4.0 I checked on several forums and they link to the version of Moq-NoCastle. I tried both this and the version in the Moq folder. Both with the same result.
I have a solution with two projects, one for my interface, one for my tests. My main project has 2 files:
IMyInterface.cs:
using System;
namespace Prototype
{
public interface IMyInterface
{
int Value { get; set; }
void ProcessValue();
int GetValue();
}
}
In my program.cs file there is only the default code generated by the project.
In my test project there is one file for my dummy test - TestProgram.cs
using System;
using NUnit.Framework;
using Moq;
namespace Prototype.UnitTests
{
[TestFixture]
public class TestProgram
{
Mock<IMyInterface> mock;
[TestFixtureSetUp]
void TestSetup()
{
mock = new Mock<IMyInterface>();
mock.Setup(x => x.GetValue()).Returns(2);
}
[Test]
public void RunTest()
{
IMyInterface obj = mock.Object;
int val = obj.GetValue();
Assert.True(val == 2);
}
}
}
, . , . , , :
"Moq.Mock`1" .
, , - ?