|
From: Owen R. <OR...@th...> - 2004-12-17 04:12:28
|
thanks jim. once you submit this, i think that we should package up a new release. cheers, owen. --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate about technology. To find out more about a career at ThoughtWorks go to http://www.thoughtworks.com/career/. Jim Arnold <JA...@th...> Sent by: nmo...@li... 17/12/2004 00:27 To: in...@ro... cc: nmo...@li..., (bcc: Owen Rogers/Canada/ThoughtWorks) Subject: Re: [Nmock-general] Problem with 'ref string[]' parameter Yes, there is a bug, but I'm a little confused by your test. NMock will only verify the value of a parameter, not the actual reference. In your test, you assign the variable 'refStringArr' to null, then pass it to your mock. This will fail (assuming the bug has been fixed) because NMock is expecting the original value assigned to strArr, which was {"a", "b"}. Even if NMock could have compared the reference refStringArr with strArr, however, it still would have failed, because they are different references. So I'm not sure what you expect the behavior to be. Anyway, I have fixed the bug, and it should make its way onto SourceForge in the next day or so. Jim ThoughtWorks -----nmo...@li... wrote: ----- To: nmo...@li... From: "web11p1" <in...@ro...> Sent by: nmo...@li... Date: 12/16/2004 05:19PM Subject: [Nmock-general] Problem with 'ref string[]' parameter Hello I've got a problem with creating a DynmicMock for a Interface with a Function that takes a 'ref string[] foo' parameter. (see example below). The function is defined as bool ByRefFunction(ref string[] strArray); the problem is that the ExpectAndReturn function of nMock didn't find the method signature (so it tells in the exception). Since some messages on the list archives showed a equal problem, i've got the latest nmock.dll from http://ccnetlive.thoughtworks.com/NMock-builds/131/ (was mentoind in a list message). Please find a example below! The ByRefFunction is suposed to cange to given array to { "a", "b" }, so the nunit tests should conform. Did i miss something or is it a bug? kind regards Dominik using System; using NUnit.Framework; using NMock; namespace Test { public interface IFoo { bool ByRefFunction(ref string[] strArray); bool Function(string[] strArray); } [TestFixture] public class FooTester { [Test] public void TestFunction() { string[] strArr = new string[] {"a", "b"}; Mock fooMock = new DynamicMock(typeof(IFoo)); fooMock.ExpectAndReturn("Function", true, (object)strArr); IFoo foo = (IFoo)fooMock.MockInstance; bool bar = foo.Function(strArr); Assert.IsTrue(bar); fooMock.Verify(); } [Test] public void TestByRefFunction() { string[] strArr = new string[] { "a", "b"}; Mock fooMock = new DynamicMock(typeof(IFoo)); fooMock.ExpectAndReturn("ByRefFunction", true, (object)strArr); string[] refStringArr = null; IFoo foo = (IFoo)fooMock.MockInstance; bool bar = foo.ByRefFunction(ref refStringArr); Assert.AreEqual("a", refStringArr[0]); Assert.AreEqual("b", refStringArr[1]); Assert.IsTrue(bar); fooMock.Verify(); } } } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Nmock-general mailing list Nmo...@li... https://lists.sourceforge.net/lists/listinfo/nmock-general ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Nmock-general mailing list Nmo...@li... https://lists.sourceforge.net/lists/listinfo/nmock-general |