Questions tagged [structuremap-automocking]

Automocking is a time-saving feature of StructureMap that allows you to easily instantiate the Class Under Test by automatically resolving the constructor dependencies of the class with Mocked out instances.

From Evolutionary Developer:
Automocking is a time-saving feature of StructureMap that allows you to easily instantiate the Class Under Test (the class that will be used in the GIVEN statement of the Scenario) by automatically resolving the constructor dependencies of the class with Mocked out instances. Test classes therefore become decoupled from the constructor(s) of the Class Under Test. Meaning that you'll get a test that fails if you change a constructor instead of a test that won't build. This is a debatable point but can be considered an advantage in TDD - you get feedback from your tests as opposed to the compiler, as it should be.
Some usage examples can be found here.

6 questions
2
votes
1 answer

How do I mock a class without an interface using StructureMap's AutoMocker?

I am huge proponent of testing and I think having to create extra interface to be able to write unit tests is small price to pay. I have added structure map automocker to test suite and it seems to be absolutely not able to mock class. Rhino mock…
1
vote
1 answer

RhinoAutoMocker Testcase fail due to Method Attribute

I have an interface public interface IMyInterface { [CustomAttribute] void MethodA(); } and the corresponding class implementing it public class MyClass: IMyInterface { public void MethodA() { //
knowdotnet
  • 839
  • 1
  • 15
  • 29
0
votes
1 answer

Function stubbed out with Structuremap Automocking not returning value

Using Josh Flanagans StructureMap Automocking overview, I'm trying my hand at it but can get the following code to return the Category object I've assigned: [Test] public void Service_Should_Return_Category_From_ID() { //…
I Clark
  • 150
  • 6
0
votes
0 answers

How to mock an injected class using NSubstitute?

I am using StructureMap for my dependency injection. I have the following repository: public class StaffRepository : NHibernateRepository, { public IEnumerable GetByStaffId(string staffId) { return…
0
votes
1 answer

XUnit, RhinoMocks, or TestDriven.Net Issue

Having some issues wrapping my head around class instantiation and TestDriven.Net(v4.0.3478) or XUnit(v2.2.0), RhinoMocks(v3.6.1), and structuremap.automocking(v4.0.0.315). Given this code: public class Tests1 { [Fact] public void…
0
votes
0 answers

how to use structureMap.autoMocking with objectFactory.BuildUp

my class is like: public class BillingAccountBLService : IBillingAccountBLService { [SetterProperty] public IContractService ContractService { get; set; } public BillingAccountBLService() { ObjectFactory.BuildUp(this); …
arielorvits
  • 5,235
  • 8
  • 36
  • 61