Completed
Last Updated: 15 Nov 2024 09:44 by ADMIN
Created by: Mihail
Comments: 2
Type: Feature Request
1
Integration with dotCover is only available through Telerik.JustMock.Configuration.exe, which works with the machine's registry and needs JustMock to be installed. This approach is not applicable to cloud-based build agents and therefore we need an integration that does not require the installation of JustMock.
Completed
Last Updated: 15 Nov 2024 09:35 by ADMIN
Created by: Ivo
Comments: 1
Type: Bug Report
2

With R3 2023 (2023.3.1011.155) JustMock introduces a new functionality that might lead to a huge performance drop and event to unexpected failures. Currently, the issue could be suppressed by setting up an environment variable JUSTMOCK_NEWOBJ_INTERCEPTION_ON_OVERWRITE_ENABLED to 0 (the default value is 1), but a more reliable and independent solution should be found.

Completed
Last Updated: 13 Nov 2024 19:11 by Drew
Created by: Drew
Comments: 2
Type: Feature Request
1

There are no ReturnsAsync methods for mocking container async methods.

There should be a set of methods to mock async methods of a container similar to regular object mocking.

As a user I should be able to write code like:

 

container.Arrange<IContainer>(r => r.SomeAsyncMethod("data")).ReturnsAsync("returnValue");

Completed
Last Updated: 13 Nov 2024 15:35 by ADMIN
Created by: Ivo
Comments: 1
Type: Feature Request
2

Collection mock (result from ReturnCollection clause) does not support async queries due to the unimplemented IAsyncQueryProvider interface. The issue could be easily reproduced with the following simple test:

[Fact]
public void ShouldReturnEntity()
{
    var db = Mock.Create<MyModel.MyModel>();
    Mock.Arrange(() => db.SomeEntities).ReturnsCollection(someEntities);

    var entity = db.SomeEntities.SingleAsync(x => x.Id == 1);

    Assert.NotNull(entity);
}

The outcome is the the following exception:

System.InvalidOperationException
The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'. Only providers that implement 'IAsyncQueryProvider' can be used for Entity Framework asynchronous operations.

Completed
Last Updated: 13 Nov 2024 15:29 by ADMIN

This article mentions a package that can be used to very easily mock Entity Framework types (mainly DbContext). However, this package only works for Entity Framework 6, and not Entity Framework Core, which my project uses. I would love to see this package updated to greatly simplify unit testing for my project.

I'm specifically looking to mock the following types: IDbContextFactory, my subclass of DbContext, and DbSet. All of this is currently possible of course with the standard JustMock interface but it's a hassle.

Completed
Last Updated: 21 Aug 2024 14:04 by ADMIN

if you use the C# using declaration and have JustMock advanced (elevated) mode enabled, the runtime will throw an InvalidProgramException.

Find below the sample code that demonstrates the issue:

public class TestClass : IDisposable
{
    public void Dispose()
    {
    }
}

[TestClass]
public class Fixture
{
    public interface ITest { }

    [TestMethod]
    public async Task Test()
    {
        ITest mock = Mock.Create<ITest>();
        using TestClass test = new();
    }
}

Completed
Last Updated: 13 Aug 2024 14:52 by ADMIN

Having the simple class

public class MyClass
{
    public event Func<EventArgs, Task>? MyEventAsync;
}
and the test that tries to rise the declared event
[TestMethod]
public void TestMethod1()
{
    var mockClass = Mock.Create<MyClass>(Behavior.Strict);
    mockClass.MyEventAsync += (args) => Task.CompletedTask;

    Mock.Raise(() => mockClass.MyEventAsync += null, EventArgs.Empty);
}

Execution triggers the following error:

Telerik.JustMock.Core.MockException : Event signature System.Threading.Tasks.Task OnMyEventAsync(System.EventArgs) is incompatible with argument types (Castle.Proxies.ExternalMockMixinProxy, System.EventArgs)

which is kind of unexpected since the supplied arguments are matching to the event's signature.

 

Completed
Last Updated: 16 May 2024 09:38 by ADMIN
Created by: Davy
Comments: 1
Type: Feature Request
0

Provide support for .NET MAUI projects. 

Let me explain in details the current situation:

I have Unit Test project using JustMock and running into a problem. It seems like JustMock is using the wrong version number to locate the SDK. let me explain:

The project is set to: <TargetFramework>net7.0</TargetFramework>

But it also has <UseMaui>true</UseMaui> enabled

I am getting the following error:

"Framework: 'Microsoft.Maui.Core', version '7.0.92' (x64)
.NET location: C:\Program Files\dotnet
No frameworks were found.

That 7.0.92 version is only for the MAUI workload version, not the SDK versions. It seems JustMock uses a workload version as a SDK version. 

Completed
Last Updated: 16 May 2024 09:28 by ADMIN
Completed
Last Updated: 30 Nov 2023 09:05 by ADMIN
Code Coverage Wrapper data collector strictly follows the installation directory structure and it makes installation-free usage really hard (with JustMock.Commercial NuGet package for example). Adding some configuration settings will solve this issue.
Completed
Last Updated: 30 Nov 2023 08:51 by ADMIN
Extend the capabilities for the creation of mock scenarios from the Visual Studio quick-action menu
Completed
Last Updated: 17 Oct 2023 12:33 by ADMIN

Considering the sample class

using Azure.Messaging.ServiceBus;

public class Class2
{
	private static ServiceBusSender messageToTopicSender;
	private static string topicName;

	public static void SetRequestTopicClient(string serviceBusConnectionString, string topName)
	{
		topicName = topName;

		ServiceBusClient serviceBusClient = new ServiceBusClient(serviceBusConnectionString);
		messageToTopicSender = serviceBusClient.CreateSender(topicName);
	}
}

and the following tests

[TestClass]
public class Class1Test
{
	[TestInitialize]
	public void SetUp()
	{
		Mock.Arrange(() => Class2.SetRequestTopicClient("", "")).DoNothing();
	}

	[TestMethod]
	public void TestA()
	{
		Class2.SetRequestTopicClient("", "");
	}
}

[TestClass]
public class Class2Test
{
	static ServiceBusClient serviceBusClient = Mock.Create<ServiceBusClient>();
	ServiceBusSender messageToTopicSender = Mock.Create<ServiceBusSender>();

	[TestInitialize]
	public void SetUp()
	{
		Mock.Arrange(() => new ServiceBusClient("conStr")).Returns(serviceBusClient);
		Mock.Arrange(() => serviceBusClient.CreateSender("myTopic")).Returns(messageToTopicSender);
	}

	[TestMethod]
	public void TestB()
	{
		Class2.SetRequestTopicClient("conStr", "myTopic");
	}
}

Executing the tests in order TestA -> TestB results in failed TestB, but changing the order or runining them standalone succeeds.The outcome of the tests should not be dependent of the execution order.

 

Completed
Last Updated: 17 Oct 2023 12:32 by ADMIN
Created by: Ivo
Comments: 1
Type: Bug Report
1

A unit test run against a simple class using EntityFramework never completes, here's the code:

public class DbContext1 : DbContext
{
    public DbContext1(string connectionString)
    {
    }
}

public class Program
{
    private static readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1);

    public async Task Run()
    {
        await _lock.WaitAsync();
        try
        {
            await InsertDbRow();
        }
        finally
        {
            _lock.Release();
        }
    }

    private static async Task InsertDbRow()
    {
        await RetryWrapperAsync(async () =>
        {
            using DbContext1 dbContext = new DbContext1("con str");
            await dbContext.SaveChangesAsync();
        });
    }

    public static async Task RetryWrapperAsync(Func<Task> operation)
    {
        for (int i = 0; i < 3; i++)
        {
            try
            {
                await operation();
                break;
            }
            catch (Exception)
            {
                await Task.Delay(100);
            }
        };
    }
}

[TestClass]
public class ProgramTest
{
    private readonly DbContext1 mockContext1 = Mock.Create<DbContext1>();

    [TestInitialize]
    public void SetUp()
    {
        Mock.Arrange(() => new DbContext1("con str")).Returns(mockContext1);
    }

    [TestMethod]
    public async Task TestMethod()
    {
        // Arrange
        Program program = new Program();

        // Act
        await program.Run(); // <-- at this point the test hangs
    }
}

Adding do-nothing arrangement on mockContext.SaveChanges fixes the hang, but the expectation is that mock will handle this case by default and there is no need to be explicitly arranged.

Completed
Last Updated: 08 Jun 2023 11:59 by ADMIN
Created by: Tomer
Comments: 12
Type: Feature Request
3

We're developing .net 5/core services, using Rider IDE and MacOS.

Please:

1. Add support to run JustMock under MacOS (profiler need to be supported, enabled issue, etc.), or if already supported, please provide instructions of how to activate it per test, for example using NUnit.

2. Add integration with Rider so all the process will be much easier.

 

Completed
Last Updated: 12 May 2023 09:34 by ADMIN

Mock.Create<IPool>() fails with 

Telerik.JustMock.Core.MockException : Abstract type 'IPool' is not accessible for inheritance.
   In Telerik.JustMock.Core.MocksRepository.Create(Type type, MockCreationSettings settings)
   In Telerik.JustMock.Mock.<>c__39`1.<Create>b__39_0()
   In Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction) 

when trying to create a mock object from

public interface IPool
{
    object GetItem(in Struct a, out Class b);
}

 

Completed
Last Updated: 05 May 2023 06:59 by ADMIN
The issue has been detected for the first time in an attempt for integration between dotTrace 2022.3.2 and JustMock 2023.R1, but it also applies to dotCover and all subsequent versions after 2022.3 of both products.
Completed
Last Updated: 14 Mar 2023 13:08 by Adam

Using elevated mocking mode (profiler enabled) with long path names for the test containers (above 260 characters) causes the following command:

dotnet test

to fail with error:

Testhost process exited with error: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main(System.String[])
. Please check the diagnostic logs for more information.

Test Run Aborted.

Completed
Last Updated: 08 Dec 2022 10:14 by ADMIN
Created by: Mihail
Comments: 1
Type: Feature Request
0
Some years ago, we committed ourselves to introduce support in Telerik JustMock for all new technology trends as soon as we can. We will introduce support for the official .NET 7 version following this commitment.
Completed
Last Updated: 08 Dec 2022 10:07 by ADMIN

There are older releases with a version of 1.0.0.4 for the Telerik.JustMock.Console.exe and with the R3 2022 release, the version is 1.0.0.3.


Completed
Last Updated: 07 Dec 2022 11:53 by ADMIN

Referencing the nuget Microsoft.ApplicationInsights.AspNetCore V2.20.0 in the project that is tested leads to the VS 2019 code coverage failing to produce the report. Here are the steps to reproduce:

1. Create a project from the template ASP.NET Core Web API targeting .NET 5

2. Add a reference to the nuget package Microsoft.ApplicationInsights.AspNetCore V2.20.0

3. Create a unit test project from the C# JustMock Test Project (.NET Core) template.

4. Run the VS code coverage.

Expected result: the code coverage report is produced.

Actual result: there is no code coverage report

1 2 3 4 5 6