Extension for Ninject aiding testability in Moq and RhinoMocks.
Questions tagged [ninject-mockingkernel]
9 questions
11
votes
1 answer
How to do Setup of mocks with Ninject's MockingKernel (moq)
I'm having a really hard time trying to figure how I can do .SetupXXX() calls on the underlying Mock that has been generated inside the MockingKernel. Anyone who can shed some light on how it is supposed to work?

larsw
- 3,790
- 2
- 25
- 37
4
votes
0 answers
Partial mocking with MockingKernel for an abstract class?
I have an abstract class with a dependency which I would like to unit test:
public abstract class BaseClass
{
public BaseClass(IDependency dep) { ... }
public virtual void TestMethod() { ... }
...
}
I want to test this class using…

ladenedge
- 13,197
- 11
- 60
- 117
3
votes
1 answer
Mock a method returning an interface with NInject Mocking Kernel
Say I have an interface like this.
public interface ICamProcRepository
{
List GetAllAitoeRedCells();
IAitoeRedCell CreateAitoeRedCell();
}
How do I mock the method which return an interface and a list of interface objects. I…

VivekDev
- 20,868
- 27
- 132
- 202
1
vote
1 answer
MockingKernel Named Multi-Bindings as constructor argument
So let's say I have an interface with two implementations
public interface IWeapon
{
string Hit(string target);
}
public class Sword : IWeapon
{
public string Hit(string target)
{
return "Slice " + target + " in half";
…

hasdrubal
- 1,024
- 14
- 30
1
vote
2 answers
Why doesn't the following mocking with Ninject.Moq work?
I'm trying to run the following code with Ninject.Moq:
[TestMethod]
public void TestMethod1()
{
var kernel = new MockingKernel();
var engine = kernel.Get();
//as I don't need to actually use the interfaces, I don't want
//to even…

devoured elysium
- 101,373
- 131
- 340
- 557
1
vote
3 answers
Using Ninject MockingKernel Moq how to inject multiple mocks for the same interface
The C# class that I wish to test accepts IEnumerable instances of the same interface. I use Ninject for dependency injection. How would I inject mocks into the IEnumerable using Ninject MockingKernel Moq
public class Foo: IFoo
{
private readonly…

JRT
- 11
- 1
- 4
0
votes
1 answer
Is partial mocking of a security a good practice?
I am introducing automatic testing using NUnit, NSubstitute for a project which uses Ninject and generic repositories.
For regression testing, I am replacing generic repositories with in memory ones to prevent working with a database.
Also, to test…

Alexei - check Codidact
- 22,016
- 16
- 145
- 164
0
votes
2 answers
Ninject MockingKernel with Saboteurs
Is it possible to use MockingKernel so that it generates mock objects automatically that, if interacted with, will throw an exception (a.k.a, saboteurs)?
This is useful when you want to get an object with various dependencies, but you know your code…

Travis Parks
- 8,435
- 12
- 52
- 85
0
votes
1 answer
Mocking with anonymous parameter
I am trying to Mock my repository layer and I have a method GetSelection(Expression> where). I am using Ninjects MickingKernel with Moq to achieve this.
When I do the following, it is fine:
// Create instance of repository
var…

Matt
- 2,691
- 3
- 22
- 36