Overmock 0.0.1-RC06

This is a prerelease version of Overmock.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Overmock --version 0.0.1-RC06                
NuGet\Install-Package Overmock -Version 0.0.1-RC06                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Overmock" Version="0.0.1-RC06" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Overmock --version 0.0.1-RC06                
#r "nuget: Overmock, 0.0.1-RC06"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Overmock as a Cake Addin
#addin nuget:?package=Overmock&version=0.0.1-RC06&prerelease

// Install Overmock as a Cake Tool
#tool nuget:?package=Overmock&version=0.0.1-RC06&prerelease                

Overmock

DOTNET Build

Overmock is a mocking framework in development that allows for creating dynamic proxies that monitor and control expected behavior when writing unit tests. Here are some examples below.

The current goal is refactoring out the dynamic proxy creation into it's own class library to be used by the testing framework.

[TestClass]
public class ExampleTestsForReadMe
{
    public class Model
    {
        public int Id { get; set; }
    }
    public interface IRepository
    {
        bool Save(Model model);
    }
    public interface ILog
    {
        void Log(string message);
    }
    public class Service
    {
        private readonly ILog _log;
        private readonly IRepository _repo;
        public Service(ILog log, IRepository repo)
        {
            _log = log;
            _repo = repo;
        }
        public void SaveModel(Model model)
        {
            try
            {
                var saved = _repo.Save(model);
                if (!saved)
                {
                    _log.Log("Failed to save");
                }
            }
            catch (Exception ex)
            {
                _log.Log(ex.Message);
                throw;
            }
        }
    }

    [TestMethod]
    public void CallsSaveTest()
    {
        var id = 22;
        var wasSaved = false;
        var log = Overmocked.ExpectAnyInvocation<ILog>();
        var repository = Overmocked.Interface<IRepository>();

        repository.Override(r => r.Save(Its.Any<Model>())).ToCall(c =>
        {
            wasSaved = true;
            return c.Get<Model>("model")?.Id == id;
        }, Times.Once);

        var service = new Service(log.Target, repository.Target);
        service.SaveModel(new Model { Id = id });

        Assert.IsTrue(wasSaved);
    }

    [TestMethod]
    public void ThrowsExceptionWhenSaveFailsTest()
    {
        var expected = "Failed to save";
        var log = Overmocked.ExpectAnyInvocation<ILog>();
        var repository = Overmocked.Interface<IRepository>();

        repository.Override(r => r.Save(Its.Any<Model>())).ToThrow(new Exception(expected));

        var service = new Service(log.Target, repository.Target);

        try
        {
            service.SaveModel(new Model());

            Assert.Fail("SaveModel Failed to throw an exception.");
        }
        catch (Exception actual)
        {
            Assert.AreEqual(expected, actual.Message);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.1 99 8/15/2024
0.1.0 90 8/9/2024
0.0.12 237 3/27/2024
0.0.11-RC01 198 10/16/2023
0.0.10 124 10/11/2023
0.0.9 108 9/17/2023
0.0.9-RD01 125 8/28/2023
0.0.9-RC03 82 9/15/2023
0.0.9-RC02 91 8/30/2023
0.0.8 154 8/27/2023
0.0.7 128 8/27/2023
0.0.7-RC04 98 8/24/2023
0.0.7-RC03 88 8/22/2023
0.0.7-RC02 87 8/19/2023
0.0.7-RC01 90 8/16/2023
0.0.6 145 8/15/2023
0.0.6-RC01 102 8/14/2023
0.0.5 137 8/14/2023
0.0.4 134 8/13/2023
0.0.3 144 8/13/2023
0.0.2 141 8/13/2023
0.0.2-RC05 115 8/13/2023
0.0.2-RC04 107 8/11/2023
0.0.2-RC03 104 8/11/2023
0.0.2-RC02 106 8/10/2023
0.0.1-RC06 95 8/10/2023
0.0.1-RC05 101 8/10/2023
0.0.1-RC01 120 12/25/2022

This is a first release and is meant for internal usages until further notice.