soorajmamar / moq

Automatically exported from code.google.com/p/moq
Other
1 stars 0 forks source link

Create VS template to ease authoring of classes with mocked dependencies #74

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. File -> New -> Test with Moq
2. Select class to test (with nice Find etc., look at upcoming type
selector from Entlib)
3. Default naming convention: class name == [selected type]Fixture.cs
4. Generates starting point (no test framework attributes on class or
method, let the user add those manually):

public class FooFixture
{
  public void TestFoo()
  {
     var dep1 = new Mock<IDep>();
     var dep2 = new Mock<IDep2>();

     var foo = new Foo(dep1.Object, dep2.Object);

     // arrange/expect

     // act

     // assert/verify
  }
}

5. Should do intelligent naming: if dependency is a class MyFoo, mock
variable should me named myFoo. if target object is named Foo, object
should be named foo, etc.

6. Would be VERY cool if we could infer at least ONE working Expect and ONE
Verify call, i.e.:

     // arrange/expect
     dep1.Expect(d => d.Save())
         .Returns(true);

     // act

     // assert/verify
     dep1.Verify(d => d.Save());

7. If there are more than 2 mocked dependencies, add the following comment
before instantiating the mocks:

     // For consistency in behavior and verification across multiple mocks,
you might want to use MockFactory.

Original issue reported on code.google.com by kzu.net on 4 Jul 2008 at 8:25

GoogleCodeExporter commented 8 years ago
Received basic VS integration features from Pablo.
Working out what's the most useful T4-driven codegen to put in there now...

Original comment by kzu.net on 16 Feb 2009 at 4:05