JustMock is a mocking framework for unit testing .NET code. The product is developed by Telerik.
Questions tagged [justmock]
104 questions
1
vote
0 answers
How can I arrange one property of my mock to set another property?
So I'm trying to mock an interface that contains a property that my unit test has to set initially, which is then altered by the subject under test, and then my assertion looks at the result.
The code under test looks like this:
public class Foo
{
…

JAF
- 385
- 1
- 2
- 12
1
vote
2 answers
How to mock with a IGenericRepository
I'm new in TDD developing and I've just started to do some tests with Nunit 3.7.1, Newtonsoft.Json version=10.0.3, JustMock Lite version 2016.2.426.1, C# and .NET Framework 4.7.
I want to test this class:
public class LoadFinishedTrzlBatch
{
…

VansFannel
- 45,055
- 107
- 359
- 626
1
vote
1 answer
Mock an Entity Framework class with JustMock inside another class
I'm using JustMock and Entity Framework to try to write unit tests for a service. In the service, I have this method:
List GetLogType(string type)
{
using (var db = new LogContext())
{
return db.Logs.Where(x => x.Type ==…

RossD
- 620
- 2
- 6
- 13
1
vote
2 answers
JustMock: Mocking private Methods
I am new to JustMock mocking framework and I am trying to mock a private method. I am fully aware that unit testing a private method is a commonly bad practice, but in this case, I have no choice. I have been looking at the official…

Angelo Charl
- 347
- 4
- 15
1
vote
2 answers
Unit testing methods on another thread
public class Composer
{
private Task _ComposerTask;
private ConcurrentQueue _Values;
public bool IsConnected { get; }
// Other dependencies
private IClient _Client;
private IWriter _Writer
public Task…

Fabio
- 31,528
- 4
- 33
- 72
1
vote
1 answer
Asp.NET MVC Arearegistration Route Unit Test With Telerik Just Mock Lite
I am trying to Asp.NET MVC Admin area route unite test with telerik just mock lite.But I cant test.
Here is My Trying Code:
[TestMethod]
public void AdminRouteUrlIsRoutedToHomeAndIndex()
{
//spts.saglik.gov.tr/admin
…

tcetin
- 979
- 1
- 21
- 48
1
vote
0 answers
Casting error working with Telerik Just Mock
UrlHelper u = new UrlHelper(ControllerContext.RequestContext);
string url = u.Action("Results", new { id = v.VerificationID });
This code above is throwing this error below when using Telerik's Just Mock while unit testing. This error does Not…

Jonathan Fishbein
- 516
- 2
- 18
1
vote
1 answer
Cannot mock simple object array with JustMock
I'm using JustMock and AutoFac and trying to mock an array of a quite simple objects but I just can't seem to get the syntax right...
var labResults = Mock.Create();
Mock.Arrange(() => labResults).Returns(new…

Mike
- 2,120
- 1
- 23
- 40
1
vote
1 answer
JustMock unit test passing when it should fail
I was writing some unit tests using JustMock and was pretty happy with myself that they were all passing until I tried to get one to fail. This unit test passes:
[TestFixture]
public class TestEventAggregation
{
class BaseEventArgs : EventArgs…

taylorjonl
- 869
- 9
- 15
1
vote
2 answers
How to get JustMocks test projects working in VisualStudio online
I have started using VisualStudio.com build services for my continuous Integration. However some of my test projects use JustMocks and I can't find an easy way to get this working in the cloud.
Has anyone got any easy methods of doing this?
Do I…

NER1808
- 1,829
- 2
- 33
- 45
1
vote
1 answer
Mocking a generic protected method
public class BaseClass
{
protected static bool GetSomething(HttpWebRequest request, out T response)
{
}
}
public class Class
{
public bool DoSomething(string arg1, string arg2, out string reason)
{
if…

user3421599
- 13
- 3
1
vote
2 answers
How to mock a private static inner class?
I'd like to ask a question which bother me a lot...
How can I mock the return value of MyPublicStaticMethod_C?? MyPrivateStaticClass_B is really private and static
public static partial class MyPublicStaticClass_A
{
private static partial…

ZHE.ZHAO
- 375
- 2
- 4
- 9
1
vote
2 answers
JustMock - How to mock a method for all instances by returning the result of the equivalent method of another class (sharing a common interface
I am working with .NET 4.5, EF6 and I'm trying to use JustMock 2.0 to test my application.
I am trying to mock my database by mocking my DbContext subclass: CoreDataRepositoryContext.
To do it, I need to mock the member SaveChanges of DbContext and…

Valone
- 41
- 7
1
vote
1 answer
How to fake arg constructor JustMock
I don't know how to fake constructor has arg
Mock.SetupStatic(typeof(A), StaticConstructor.Mocked);
with Class A has Constructor arg s:
public A(string s)
{}
Please help me! Thanks.

Nhat Duy
- 198
- 1
- 2
- 11
1
vote
1 answer
Exception Using PrivateAccessor
I'm trying to set up a simple test to demonstrate how to mock a private method, but when I run it, I get the following exception:
An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code
Additional…

Nathan A
- 11,059
- 4
- 47
- 63