|
From: Joe W. <jo...@tr...> - 2003-02-27 07:54:00
|
Good idea. I'll work these in over the weekend. And I still think this is the most awesome way to submit bugfix/feature requests. -joe Jeremy Stell-Smith wrote: >this is more just things I find really annoying. >Mostly that NMock should fail early and tell you why >it won't do what you're trying to make it do... > >__________________________________________________ >Do you Yahoo!? >Yahoo! Tax Center - forms, calculators, tips, more >http://taxes.yahoo.com/ > >------------------------------------------------------------------------ > >using System; > >using NUnit.Framework; >using NMock; > >namespace Pilot.Fit.Test >{ > /// <summary> > /// looking at the code, I think fixing this for one case (SetupResult or Expect) > /// should fix it in all places (at least that's the intent) > /// > /// I didn't use ExpectException because I wanted to specify the error message > /// </summary> > [TestFixture] > public class FastErrorHandlingTest : Assertion > { > public class Empty > { > } > > public class Full > { > public string Foo() > { > return "foo"; > } > > public virtual string Bar(string s) > { > return "bar"; > } > } > > private IMock empty; > private IMock full; > > [SetUp] > public void SetUp() > { > empty = new DynamicMock(typeof(Empty)); > full = new DynamicMock(typeof(Full)); > } > > [Test] > public void SetupResultWithNoMethod() > { > try > { > empty.Expect("Foo"); > Fail(); > } > catch (MissingMethodException e) > { > AssertEquals("method <Foo> not defined", e.Message); > } > } > > [Test] > public void SetupResultWithWrongType() > { > try > { > full.SetupResult("Foo", true); > Fail(); > } > catch (ArgumentException e) > { > AssertEquals("method <Foo> returns a System.String", e.Message); > } > } > > /// <summary> > /// this is HUGE, I keep trying to mock non-virtual methods and wasting tons of time trying to figure > /// out why my tests are working :) > /// </summary> > [Test] > public void MethodNotVirtual() > { > try > { > full.Expect("Bar"); > Fail(); > } > catch(ArgumentException e) > { > AssertEquals("method <bar> not virtual", e.Message); > } > } > } >} > > |