Unplanned
Last Updated: 27 Jun 2023 09:47 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
1
In-Assembly Parallel (IAP) significantly reduces the time for test execution, but currently JustMock does not support it.
Unplanned
Last Updated: 23 Jun 2023 09:42 by ADMIN

Dear Telerik team,
It is nice to have a way to generate mocks.

But it is annoying to have lots of those messages for references in XML comments. I had to turn the feature off. Which might be the case for other customers too.

Maybe you want to have a look into it.


Unplanned
Last Updated: 10 May 2023 08:22 by ADMIN
ADMIN
Created by: Kamen Ivanov
Comments: 3
Type: Feature Request
5

			
Unplanned
Last Updated: 25 Apr 2023 15:53 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
0

JustMock interprets anonymous types as tuples. The sample below demonstrates the issue:

public interface IAnsweringService
{
    (int code, string desc) GetAnswer(string question);
}


[TestMethod]
public void AnswerToTheUniverseQuestionTest()
{
    var apiMock = Mock.Create<IAnsweringService>();

    var expectedAnswer = new { code = 42, desc = "Answer to the Ultimate Question of Life" };

    Mock.Arrange(() => apiMock.GetAnswer(Arg.AnyString)).Returns(expectedAnswer);

    var actualAnswer = apiMock.GetAnswer("What is a universe question answer?");

    Assert.AreEqual(expectedAnswer.code, actualAnswer.code);
    Assert.AreEqual(expectedAnswer.desc, actualAnswer.desc);
}
The test fails with error:

Telerik.JustMock.Core.MockException: The chained return value type '<>f__AnonymousType1`2[System.Int32,System.String]' is not compatible with the arranged method's return type 'System.ValueTuple`2[System.Int32,System.String]'

Unplanned
Last Updated: 19 Apr 2023 09:59 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
0
The DoIntead API cannot be used in scenarios that require the method call arguments to be captured and a specific return value to be provided.
Unplanned
Last Updated: 13 Apr 2023 08:40 by Ivo

The following code snippet causes a hang in the test execution while being debugged:

Mock.SetupStatic(typeof(TimeSpan), Behavior.CallOriginal, StaticConstructor.NonMocked);
Mock.Arrange(() => TimeSpan.FromSeconds(15)).Returns(TimeSpan.MinValue);

The issue can be temporary solved by disabling the DebugWindow via JustMock extension menu. 

Unplanned
Last Updated: 15 Mar 2023 06:42 by Quoc Tin

Hello

I generate a syntax tree which I will format with Formatter.Format() from the package Microsoft.CodeAnalysis.CSharp.Workspaces 4.4.0 and .NET 6. A test exists where the formatter is used but when the JustMock profiler is enabled an InvalidProgramException is thrown. When the profiler is disabled everything works fine. It fails on Windows and on Linux.

Exception

  Message: 
System.InvalidProgramException : Common Language Runtime detected an invalid program.

  Stack Trace: 
ContextIntervalTree`2.ctor(TIntrospector& introspector)
FormattingContext.ctor(AbstractFormatEngine engine, TokenStream tokenStream)
AbstractFormatEngine.CreateFormattingContext(TokenStream tokenStream, CancellationToken cancellationToken)
AbstractFormatEngine.Format(CancellationToken cancellationToken)
CSharpSyntaxFormatting.Format(SyntaxNode node, SyntaxFormattingOptions options, IEnumerable`1 formattingRules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken)
AbstractSyntaxFormatting.GetFormattingResult(SyntaxNode node, IEnumerable`1 spans, SyntaxFormattingOptions options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.GetFormattingResult(SyntaxNode node, IEnumerable`1 spans, Workspace workspace, OptionSet options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.Format(SyntaxNode node, IEnumerable`1 spans, Workspace workspace, OptionSet options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.Format(SyntaxNode node, Workspace workspace, OptionSet options, CancellationToken cancellationToken)
UnitTest1.Test1() line 23

Reproduction

You can reproduce this by writing an unit test for that (I used xUnit):

        [Fact]
        public void Test1()
        {
            var classText = @"using System; namespace TestNameSpace.Orders { public class Order
                            {
                                public Guid Id { get; set; }
                            }
                        }";

            var syntaxTree = CSharpSyntaxTree.ParseText(classText);
            var workspace = new AdhocWorkspace();

            var formattedClassText = Formatter.Format(syntaxTree.GetRoot(), workspace).ToFullString();

            var expected = @"using System;
namespace TestNameSpace.Orders
{
    public class Order
    {
        public Guid Id { get; set; }
    }
}";
            Assert.Equal(expected, formattedClassText);
        }
    }

System Info

JustMock

See attachments. We do not use the free edition.

.NET

dotnet --info
.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.200\

Host:
  Version:      7.0.3
  Architecture: x64
  Commit:       0a2bda10e8

.NET SDKs installed:
  6.0.406 [C:\Program Files\dotnet\sdk]
  7.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

 

I already posted a question but can't delete it anymore: InvalidProgramException thrown when formatting SyntaxNodes in JustMock | Telerik Forums
Unplanned
Last Updated: 25 Jan 2023 10:55 by Ivo

Considering the following simple test scenario:

public abstract class TestBase
{
    public static TestContext TestContext { get; set; }
}

[TestClass]
public class UnitTest1 : TestBase
{
    [ClassInitialize]
    public static void ClassInitlialize(TestContext ctx)
    {
        TestContext = ctx;
    }

    [TestMethod]
    public void TestMethod1()
    {

    }
}

[TestClass]
public class UnitTest2 : TestBase
{
    [ClassInitialize]
    public static void ClassInitlialize(TestContext ctx)
    {
        TestContext = ctx;
    }

    [TestMethod]
    public void TestMethod1()
    {

    }
}

Attempt to run the tests above with JustMock profiler enabled fails with System.InvalidProgramException. The issue is not reproducible with MSTest.TestFramework and MSTest.TestAdapter packages prior to 3.0.x.

 

Unplanned
Last Updated: 11 Jan 2023 11:08 by Ivo

The issue is demonstrated with the following sample:

[Theory]
[MemberData(nameof(GetMemberDataContext))]
public void ValidParameters_Success(int param1, int param2)
{
	// Arrange
	Mock.SetupStatic(typeof(MyClass), Behavior.Strict, StaticConstructor.Mocked);
        Mock.Arrange(() => MyClass.method1()).Returns(true);

        // Act
	IService service = new Service();
	bool result = service.method2();

	// Assert
	Assert.True(result);
	Mock.Assert(() => MyClass.method1(), Occurs.Once()); // <-- the test fails here because it reports that method invocation occurs twice
}

The issue in not observed if the code is modified in the following way, which indicates behavioral incinsistency:

[Theory]
[MemberData(nameof(GetMemberDataContext))]
public void ValidParameters_Success(int param1, int param2)
{
	// Arrange
	Mock.SetupStatic(typeof(MyClass), Behavior.Strict, StaticConstructor.Mocked);
        Mock.Arrange(() => MyClass.method1()).Returns(true).OccursOnce();

        // Act
	IService service = new Service();
	bool result = service.method2();

	// Assert
	Assert.True(result);
	Mock.Assert<MyClass>();
}
 

Unplanned
Last Updated: 03 Jan 2023 16:56 by ADMIN
Created by: Mihail
Comments: 2
Type: Feature Request
1
Consider the scenario where a class has a string field which is his main data. This class has defined an implicit cast operator to string. When that cast operator is executed the resulted string will contain the value from the class field.

Implement support for mocking of an operator such as the one described. 
Unplanned
Last Updated: 10 Nov 2022 09:40 by Ivo
Mocking of these methods could not be made due to compiler (CS8175) or runtime (System.InvalidProgramException: Cannot create boxed ByRef-like values) errors.
Unplanned
Last Updated: 17 Oct 2022 12:22 by Ivo

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();
    }
}

Unplanned
Last Updated: 01 Sep 2022 07:21 by ADMIN
Created by: Mihail
Comments: 1
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.
Unplanned
Last Updated: 04 Jul 2022 11:41 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
1

The threading model of UI apps differs from the test host and this might become a source of issues like the following: System.InvalidOperationException: "The calling thread must be STA, because many UI components require this". The request is about extending JustMock with some helpers that can be used to solve this issue easily.

Unplanned
Last Updated: 18 Jan 2022 09:35 by ADMIN
A documentation article should be added that explains how to integrate JustMock to work within JetBrains Rider
Unplanned
Last Updated: 01 Dec 2021 14:06 by ADMIN
Created by: Ivo
Comments: 0
Type: Feature Request
1
Coverlet (https://github.com/coverlet-coverage/coverlet) is a cross-platform .NET code coverage tool, so the integration should be considered for all currently (and also potentially) supported platforms by JustMock.
Unplanned
Last Updated: 01 Dec 2021 13:59 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.

 

Unplanned
Last Updated: 16 Nov 2021 10:04 by ADMIN
Adding JustMock to the Extensions section under Assemblies in the Add Reference dialog will make it easier for the developers to find where the required dll is located.
Unplanned
Last Updated: 07 Oct 2021 14:06 by ADMIN
Created by: Alan
Comments: 4
Type: Feature Request
2
I am in the process of building an internal developer platform on kubernetes. Historically, in order to run justmock on build servers we pointed to a special location of the windows registry for accessing the DLL. In kubernetes, the build runners are kubernetes nodes. Is there a preferred way to run these tests in this environment? I can provide more details if it is helpful or valuable. Historically, we used Azure Devops build agents in this new world dotnet test is being run in Linux gitlab agents and not windows. I would have chosen linux in the dropdown but wasn't available.
Unplanned
Last Updated: 19 Aug 2021 07:54 by ADMIN

The new public API should allow the developer to access the invocations for a particular arrangement. Something like the following:

IEnumerable<IInvocaiton> invocations = foo.GetInvocationsFor((x) => x.CalcData(2, 2));

1 2 3