JustMock is a mocking framework for unit testing .NET code. The product is developed by Telerik.
Questions tagged [justmock]
104 questions
3
votes
0 answers
Unit test failing assertion in async unit test
I am trying to unit test some async code. I was previously using NUnit but would like to switch to Xunit but I can't get some tests working. Here is some example code for some working NUnit tests that I simplified for the sake of asking this…

taylorjonl
- 869
- 9
- 15
3
votes
1 answer
Casting ActionResult as HttpNotFoundResult returns null
I have a unit test for my controller that asserts that an HttpNotFoundResult is returned when an instance of the model is not found. The problem is, the actual code in the controller is working as intended, but my unit test is not. When casting the…

Soldat1988
- 67
- 1
- 7
3
votes
2 answers
Mocked Object Still Making Calls to Service
So I'm writing tests for our MVC4 application and I'm testing Controller actions specifically. As I mention in the title, the test still hits the service (WCF) instead of returning test data. I have this controller:
public class FormController :…

mmcclannahan
- 1,608
- 2
- 15
- 35
2
votes
2 answers
JustMock multiple Mocks of same interface
In our solution we used to have a really ancient version of JustMock. We wrote around 7000 tests and one pattern that would sometimes emerge is to have a default mock of a certain interface for all test-cases and in some tests "override" that…

danielspaniol
- 2,228
- 21
- 38
2
votes
1 answer
Mock.Create<>() requiring strong name
I have the following dependency tree
MyFramework
DataAccess
Processor
Processor.Tests
Each assembly references on all of the ones above it. So Processor.Tests references Processor, DataAccess, and MyFramework. With the exception of ProcessorTests…

Jeremy Hutchinson
- 1,975
- 16
- 26
2
votes
1 answer
Unit Testing : Raise Event From Nested Type
I have an Interface which has a property on another interface,
public interface IInnerInterface
{
event EventHandler OnCompleted;
}
public class InnerClassImplementation : IInnerInterface
{
public event EventHandler OnCompleted;
…

Raajkumar
- 857
- 2
- 13
- 26
2
votes
1 answer
Using JustMock, how can I test if a method was called twice with different objects passed into it?
I have a piece of logic which is inserting a Product Model into a repository. The piece of logic will be inserting two product models both with different data into the repository and I need to test that this method is only called twice, once for…

Eritey
- 143
- 1
- 2
- 11
2
votes
1 answer
Problems in creating unit test for ASP .NET MVC
I am creating some unit tests for my ASP .NET MVC Controller class and I ran into some very strange errors:
My controller code is below:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(JournalViewModel journal)
{
var…

Felipe
- 6,312
- 11
- 52
- 70
2
votes
3 answers
Mocking constructor call in Justmock fails for UrlHelper
In justmock we can return mocked instances instead of actual instances by Arranging the constructor call like
Mock.Arragne(()=>new MyClass(Arg.IsAny())).IgnoreInstance().Returns(Mock.Create());
but when I tried the same with…

Necromancer
- 194
- 3
- 13
2
votes
2 answers
Can I handle case insensitive string in my mock?
NUnit 3.4.1, JustMock 2016.2.713.2
I have the class under test:
public class AppManager {
public string[] GetAppSets() => Registry.LocalMachine
.OpenSubKey(@"SOFTWARE\Autodesk\AutoCAD", false)
?.GetSubKeyNames();
}
Also, I have…

Andrey Bushman
- 11,712
- 17
- 87
- 182
2
votes
4 answers
Are there any ways to mock entity framework calls that create new connections directly within methods
I am new to unit testing and mocking. The project I am working on has many methods that look like this:
public bool MyMethod(int param, int param2)
{
using (SomeEntity dBcontext = new SomeEntity())
{
FancyObj theobj =…

TacticalMin
- 791
- 2
- 7
- 18
2
votes
2 answers
JustMock vs Moq
In order to write Unit Tests, I need to integrate a mocking framework for my WinRT based application and decide on which mocking framework would be a best fit. I ended up comparing JustMock (licensed version) and Moq. I could not find a detailed…

tavier
- 1,744
- 4
- 24
- 53
2
votes
1 answer
Entity Framework: Mocking with JustMock
I've just installed the Telerik.JustMock.EntityFramework package, and i am trying it.
I've tried this:
var ctx = EntityFrameworkMock.Create().PrepareMock();
var source = new List()
{
new…

ascherman
- 1,762
- 2
- 20
- 41
2
votes
4 answers
JustMock - check value of passed method argument
I use JustMock framework and have the following assertion:
Mock.Assert(() => activityListenerMock.PeriodPassed(
Arg.Matches(e => e.Length == expectedLength)));
It fails with cryptic message:
Occurrence expectation failed. Expected at…

Krzysztof Kot
- 648
- 1
- 10
- 15
2
votes
1 answer
How to correctly test method with return type of an enum using justmock/moq
I am currently having issues with testing a method which my controller uses which is mocked. it has a return type of an specific enum. I am currently always getting back from this mocked method the default enum value, not the value that I have…

Dan Head
- 23
- 3