JustMock is a mocking framework for unit testing .NET code. The product is developed by Telerik.
Questions tagged [justmock]
104 questions
2
votes
1 answer
JustMock: Mocking By Example ToString Evaluation
When I attempt the following JustMock:
var mockedField = Mock.CreateLike(field => field.DisplayName == "Test Display");
I get the following error:
at Sitecore.Data.Fields.Field.GetValue(Boolean allowStandardValue, Boolean…

Spicy Koala
- 557
- 3
- 9
2
votes
1 answer
Trying to Unit Test an Event with JustMock
I am trying to write a Unit Test using JustMock that ignores an Event.
I do not want to test the Event itself, as it calls all sorts of internal functions that would require a massive amount of effort to Mock.
Here is a quick bit of example…

Steve
- 1,779
- 1
- 11
- 12
2
votes
2 answers
Equivalent of JustMock's ReturnsCollection() in FakeItEasy?
With JustMock I can mock DataContext tables with lists in Linq to SQL easily like this, where an IEnumerable is taking the place of each DataContext's table through ReturnsCollection() allowing me to plug in fake data:
[TestMethod]
public void…

frontsidebus
- 120
- 1
- 9
1
vote
2 answers
is there a better way to test this method?
I would like to run some unit tests on the method below I am passing a mocked interface(vehicleObject) into ProcessVehicles but as soon as it is passed it gets reassigned by DetermineVehicleType so my mocked object is of no use. My first idea would…

Micah Armantrout
- 6,781
- 4
- 40
- 66
1
vote
0 answers
abstract type 'Microsoft.Extensions.Options.IOptions'1' is not accessible for inheritance - UnitTests
I have a small problem with running the unit tests with dotnet CLI. I am using xUnit and JustMock.
I have a class called 'DevOpsOptions' which is a internal and located in UserManagement project.
Example:
internal class DevOpsOptions
{
…

Ali Hasan
- 121
- 8
1
vote
0 answers
Mock.Arrange what does it actually do?
I am new to testing and new to JustMock.
I have written my first test.
[TestMethod]
public void CheckifExportToCSVIsSuccessfull()
{
C1FlexGrid c1flexGrid = new C1FlexGrid();
C1FlexGridBase c1flexGridBase =…

Shezad Ahmed
- 69
- 1
- 6
1
vote
1 answer
How to mock an interface property with JustMock in VB.NET
I am using JustMock to mock interfaces for unit testing, but perhaps I'm not doing it right.
I have an interface:
Public Interface IFoo
Property Bar as int
End Interface
I want to mock this interface and set that property so that it can be read…

Matthew
- 10,244
- 5
- 49
- 104
1
vote
3 answers
How can I mock multiple instances of a struct?
I have a struct that I want to mock. In a more complex test I need several instances of this struct, each with it's own behavior. To facilitate this, I've created a helper method.
private MyStruct CreateMock(string toString) {
var mock =…

Timo
- 2,212
- 2
- 25
- 46
1
vote
1 answer
Mocking out parameters with JustMock
I am writing unit tests and I need to mock the out parameter of the one of the target method dependencies with the following signature:
bool TryProcessRequest(out string)
I am using JustMock and I have tried to use DoInstead arrangement clause,…

Dioniss
- 23
- 3
1
vote
0 answers
Can't mock an extension method wtih JustMock
I am trying to mock an extension method with justmock. For some reason it throws the following error:
"Test method TestProject1.JustMockTest.TestMethod threw exception:
Telerik.JustMock.Core.ElevatedMockingException: Cannot mock 'TestProject1.Foo'.…

Dioniss
- 23
- 3
1
vote
0 answers
JustMock capture return value of CallOriginal
I was wondering if there was a way/workaround to be able to capture the output from an Arrange call in JustMock.
e.g. this is the kind of thing that I would like to do:
Mock.Arrange(() => foo.Bar()).CallOriginal(result => { /* stuff I want to do…

Jose S
- 29
- 2
1
vote
2 answers
JustMock helpers in another class return null in test
I moved the most frequently created mocks into extensions and helper classes to be able to reuse them in several tests. I was very surprised when it turned out that they are appently context dependent and don't work when sitting elsewhere.
This code…

t3chb0t
- 16,340
- 13
- 78
- 118
1
vote
1 answer
Asserting a property has been set in a mocked class
I'm using the MockingContainer to automatically set up my dependencies. How do I assert that a property on one of those dependencies gets set?
[SetUp]
public void SetUp()
{
//arrange
_baseUrl = "http://baseUrl";
_container = new…

gilliduck
- 2,762
- 2
- 16
- 32
1
vote
1 answer
JustMock partial class, mock private method
I want to mock a partial class with a private method. But the arranged method is not called. Instead just the normal one. I don't get any errors. It's not relevant what GetAppleModel originally does since it shouldn't do anything in my Test Case. I…

Thypari
- 801
- 1
- 6
- 22
1
vote
0 answers
JustMock and XUnit - Derived class test results getting ignored when mocking SQLConnection
I'm mocking SQLConnection for my derived class tests and noticed that it seems to make XUnit(?) ignore the results.
Example to reproduce behavior:
using System.Data.SqlClient;
using System.Threading.Tasks;
using Telerik.JustMock;
using…

user7003875
- 121
- 6