Emulates the most popular syntaxes

DynMock has no syntax of its own and emulates the Moq, NSubstitute, and FakeitEasy syntax:

using NUnit.Framework;
using SysSurge.DynMock.Syntax.Moq;

namespace SysSurge.DynMock.Tests.Moq
{
    [TestFixture]
    public class GenericTests
    {
        [Test]
        public void MockActionReturnInt()
        {
            var mock = new Mock<IMotorist>();
            mock.Setup(foo => foo.GetAge()).Returns(1);
            var age = mock.Object.GetAge();
            Assert.AreEqual(1, age);
        }

}
using NUnit.Framework;
using SysSurge.DynMock.Syntax.NSubstitute;

namespace SysSurge.DynMock.Tests.NSubstitute
{
    [TestFixture]
    public class GenericTests
    {
        [Test]
        public void MockActionReturnInt()
        {
            var driver = Substitute.For<IMotorist>();
            driver.GetAge().Returns(1);
            var age = driver.GetAge();
            Assert.AreEqual(1, age);
        }

}
using NUnit.Framework;
using SysSurge.DynMock.Syntax.FakeItEasy;

namespace SysSurge.DynMock.Tests.FakeItEasy
{
    [TestFixture]
    public class GenericTests
    {
        [Test]
        public void Mock_Method_Return_Int()
        {
            var driver = A.Fake<IMotorist>();
            A.CallTo(() => driver.GetAge()).Returns(1);
            var age = driver.GetAge();
            Assert.AreEqual(1, age);
        }

}

Mock dynamic objects

DynMock extends Moq, NSubstitute, and FakeItEasy with support for mocking of dynamically objects.

using System;
using System.Dynamic;
using NUnit.Framework;
using SysSurge.DynMock.Syntax.FakeItEasy;

namespace SysSurge.DynMock.Tests.FakeItEasy
{
    [TestFixture]
    public class Wrapping_Tests
    {
        [Test]
        public void Dynamic_Mock_Return_String()
        {
            dynamic wrappedDynamic = new ExpandoObject();
            wrappedDynamic.First = "Jane";
            wrappedDynamic.Last = "Doe";
            wrappedDynamic.StringFunction = new Func<string>(() => wrappedDynamic.First + " " + wrappedDynamic.Last);
            var name = wrappedDynamic.StringFunction();
            Assert.AreEqual("Jane Doe", name);

            var person = A.Fake<IMisc>(x => x.Wrapping(new[] { wrappedDynamic }));
            A.CallTo(() => person.StringFunction()).Returns("Mocked name");
            name = person.StringFunction();
            Assert.AreEqual("Mocked name", name);
        }
}