Maxim Peshkov

AssemblyInitialize Mock.SetupStatic

I have logging class which are using everywhere.
I want to Mock this class for all tests. And i tried to use AssemblyInitialize but got problem. I have simulated this problem with JustMock.ElevatedExamples.AdvancedUsage examples:
1) Add BaseTest class
[TestClass]
public class BaseTest
{
[AssemblyInitialize()]
public static void AssemblyInit(TestContext context)
{
Mock.SetupStatic(typeof(Common1), StaticConstructor.Mocked);
// Arranging: When the static(Foo.FooProp_GET) property is called, it should return expected.
var fakeUsed = Mock.Create<LogWriter1>(Constructor.Mocked);
Mock.Arrange(() => Common1.Log).Returns(fakeUsed);
}

[AssemblyCleanup]
public static void Cleanup()
{
//clean up stuff here
}
}
public static class Common1
{
static Common1()
{

Log = new LogWriter1();

}

public static LogWriter1 Log { get; set; }

}

public class LogWriter1
{

}

2) When run test from VS - all ok
3) When run from command line it is not working. Show Message box "Process Starts Now".

SET JUSTMOCK_INSTANCE=1
SET COR_ENABLE_PROFILING=1
SET COR_PROFILER={B7ABE522-A68F-44F2-925B-81E7488E9EC0}
"C:\Program Files (x86)\Telerik\JustMock\Libraries\JustMockRunner.exe" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcontainer:"D:\test\CSExamples\JustMock.ElevatedExamples\bin\Debug\JustMock.ElevatedExamples.dll"

How i can mock logger for all test? It is static public property.

I use MS Test + VS 2015.
Problem by Maxim Peshkov Status: New Comments: 0 Last update: 2017-04-19T08:19:08 by Maxim Peshkov
0
Kamen Ivanov
Team Member

Support for named parameters in Mock.Arrange

It would be good if we could use named parameters inside Mock.Arrange method.
Feature Request by Kamen Ivanov Status: New Comments: 0 Attachments: 1 Last update: 2017-04-07T07:00:10 by Kamen Ivanov
0
Sean Mackedie

Exception when mocking three or more layers deep with CreateLike<>

When using Mock.CreateLike<> we've found that trying to directly mock anything lower than two layers down on a concrete class (e.g. x => x.Layer1.Layer2.Property == "test") throws a NullReferenceException unless the profiler is enabled. It wasn't clear in the exception or the documentation relating to this method that the real issue was the profiler being disabled, and only by trial and error did we find the solution.
Problem by Sean Mackedie Status: New Comments: 0 Last update: 2017-03-22T07:40:19 by Sean Mackedie
0
Kamen Ivanov
Team Member

Add integration with CodeRush

Feature Request by Kamen Ivanov Status: New Comments: 0 Last update: 2017-03-08T15:10:21 by Kamen Ivanov
0
Kamen Ivanov
Team Member

Tests fail when run via vstest.console but pass when run from VS2015

Tests fail when run with vstest.console.exe but pass when run from VS2015
Problem by Kamen Ivanov Status: New Comments: 0 Last update: 2017-03-07T15:02:28 by Kamen Ivanov
0
Human Amdjadi-Bigwand

I want to check the order of methode calls but InSequence() does not work

I want to check the order of methode calls but InSequence() does not work for it.

Feedback by Human Amdjadi-Bigwand Status: Rejected Comments: 3 Last update: 2016-08-17T08:54:25 by Vladimir Dragoev
0
Michele Sinesi

justmock

In Visual Studio 2015 Pro justmock generates this error error MSB6006: "vbc.exe" To function properly you need to uninstall VS2015 justmock.

Bye
Problem by Michele Sinesi Status: New Comments: 3 Last update: 2016-08-02T22:08:40 by Jeremy Simmons
0
Brian Stanton

resharper 10

Resharper 10 code coverage have tests failing when arrange to have JustMock to return values from methods called under test. Perhaps one tool too many manipulating .NET objects behind-the-scenes at a time?
Problem by Brian Stanton Status: New Comments: 1 Last update: 2015-12-18T15:35:53 by Brian Stanton
0
William Cowell

Mocking WinRT using helper methods to create mocks

My team and I have spotted some odd behaviour with the latest version of JustMock (2015.3.929.5) when targeting a Windows Store app.

If we create a mock for an object in a helper method, the mock fails when making assertions for calls to the mock.

The following code illustrates the issue:

[TestMethod]
public void ThisWillFail()
{
var subject = CreateSubject();

subject.DoSomething();

subject.Assert(s => s.DoSomething(), Occurs.Once());
}

[TestMethod]
public void ThisWillPass()
{
var subject = Mock.Create<ISubject>();

subject.DoSomething();

subject.Assert(s => s.DoSomething(), Occurs.Once());
}

public interface ISubject
{
void DoSomething();
}

private static ISubject CreateSubject()
{
return Mock.Create<ISubject>();
}

In this code, the first test will fail but the second test will pass. The only difference is that, in the first test, we're setting up the mock in a helper method.

We have a "Unit Test Library (.NET for Windows Store apps)" referencing the Telerik.JustMock assembly. I have attached a simple project containing this implementation.

It's worth noting that the same code passes in a regular .NET class library; it only fails in a "Unit Test Library (.NET for Windows Store apps)". It's also worth noting that this worked under an older version of the assembly (2014.3.1021.2).

Any help would be appreciated, as we currently have around 3,000 tests and a good proportion of them set up their mocks using a helper method in this way.

Regards
William Cowell
Problem by William Cowell Status: New Comments: 2 Attachments: 1 Last update: 2015-12-01T11:51:09 by Stefan Dragnev
0
Anand Rau

Mock.SetupStatic not working with RoleEnvironment

I have installed the trial version of JustMock to evaluate it. I have been trying to mock the static calls of Azure RoleEnvironment class, but the SetupStatic does not work. It seems to be calling the original method. Please see my simple test below:

[Test]
public void VerifyRoleEnvironment()
{
bool expected = true;
Mock.SetupStatic(typeof(RoleEnvironment), StaticConstructor.Mocked);
Mock.Arrange(() => RoleEnvironment.IsAvailable).Returns(true);
Assert.AreEqual(expected, RoleEnvironment.IsAvailable);
}
Problem by Anand Rau Status: Completed Comments: 1 Last update: 2015-11-24T08:37:22 by Simo Hauml
0
Displaying items 1 - 10 of 51