Silverlight Support for NSubstitute

50 views
Skip to first unread message

JasonBock

unread,
Jan 13, 2012, 9:47:45 AM1/13/12
to NSubstitute
I'm going to be working on a project that's SL-based. I'd love to use
NSubstitute for the tests, but it appears that it doesn't have SL
support just there. There's been work on it (http://groups.google.com/
group/nsubstitute/browse_thread/thread/418fddb4068227ec/
d395b98c5b377573?lnk=gst&q=silverlight#d395b98c5b377573) but unless
I'm mistaken this hasn't made it into the release version just yet. Is
this something that will happen?

Regards,
Jason

David Tchepak

unread,
Jan 13, 2012, 10:01:03 AM1/13/12
to nsubs...@googlegroups.com
Hi Jason,

It's not ready for release yet, but you are welcome to give it a go by building using "rake target=SL" (or "build.sh target=SL" from the project root directory). There are some progress notes here: https://github.com/nsubstitute/NSubstitute/wiki/Silverlight-port

IIRC Brendan had a large number of tests passing, to the point where it should work ok, but as it hasn't been tested thoroughly I've avoiding promoting it to a release build. I don't use SL, so I really need an SL dev to give it the green light before it can be released.

I'm happy to work with you to try and resolve any issues you have getting it going, as it would be great to get SL supported for future releases.



--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To post to this group, send email to nsubs...@googlegroups.com.
To unsubscribe from this group, send email to nsubstitute...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nsubstitute?hl=en.


Martin Hollingsworth

unread,
Jan 23, 2012, 12:41:51 AM1/23/12
to NSubstitute
I've just started trying to get this working for Silverlight 4 and
here are a few things that I encountered.

1) https://github.com/nsubstitute/NSubstitute/blob/master/Source/NSubstitute/Core/CallStack.cs
line 59 does not compile.The line in question is:
public T[] ToArray() { LockedAction(() => _stack.ToArray()); }

I think the implementation below should match the intent and seems to
work for me

            public T[] ToArray()
            {
            T[] array = default(T[]);
            LockedAction(() => array = _stack.ToArray());
            return array;
            }

2) NSubstitute\Source\NSubstitute.Acceptance.Specs
\NSubstitute.Acceptance.Specs.csproj line 249 and \NSubstitute\Source
\NSubstitute.Specs\NSubstitute.Specs.csproj line 303 were:
<SilverlightLibraryPath>$(ProgramFiles32)\Microsoft Silverlight
\4.0.60831.0</SilverlightLibraryPath>

I had a different build number  (4.0.60531.0 as I had not applied a
security patch yet) but perhaps changing it to the line below would
make the build more tolerant. These are the same files that  are being
referenced by the projects as assemblies in any case when it is built
as SL40.
      <SilverlightLibraryPath>$(ProgramFiles32)\Reference Assemblies
\Microsoft\Framework\Silverlight\v4.0</SilverlightLibraryPath>

3) After those changes I was able to get the solution to build in
Visual Studio 2010. The build instruction on the wiki page (rake
target="SL40") doesn’t actually trigger the build at the moment
because https://github.com/nsubstitute/NSubstitute/blob/master/Build/rakefile
line 13 does not include the “SL40” target. After including the target
again, the build runs successfully with 213 tests passing, 4 Ignored
(as per the wiki page) and none fail. Looking at the tests within the
solution it seems like the build is not running a significant number
of the tests but I haven't got round to investigating any of these
yet.

Martin Hollingsworth

unread,
Jan 23, 2012, 12:49:31 AM1/23/12
to NSubstitute
I've been trying this out with Silverlight 4 and found the following:

1) https://github.com/nsubstitute/NSubstitute/blob/master/Source/NSubstitute/Core/CallStack.cs
line 59 does not compile. The line in question is:

public T[] ToArray() { LockedAction(() => _stack.ToArray()); }

I think the implementation below should match the intent and seems to
work for me

public T[] ToArray()
{
T[] array = default(T[]);
LockedAction(() => array = _stack.ToArray());
return array;
}

2) NSubstitute\Source\NSubstitute.Acceptance.Specs
\NSubstitute.Acceptance.Specs.csproj line 249 and NSubstitute\Source
\NSubstitute.Specs\NSubstitute.Specs.csproj line 303 were

<SilverlightLibraryPath>$(ProgramFiles32)\Microsoft Silverlight
\4.0.60831.0</SilverlightLibraryPath>

I had a different build number (4.0.60531.0 as I had not applied a
security patch yet) but perhaps changing it to the line below would
make the build more tolerant and these are the same files that are
being referenced by the projects as assemblies in any case when it is
built as SL40.

<SilverlightLibraryPath>$(ProgramFiles32)\Reference Assemblies
\Microsoft\Framework\Silverlight\v4.0</SilverlightLibraryPath>

After those changes I was able to get the solution to build in Visual
Studio 2010. The build instruction on the wiki page (rake
target="SL40") doesn’t actually trigger the build at the moment
because https://github.com/nsubstitute/NSubstitute/blob/master/Build/rakefile
line 13 does not include the “SL40” target.

After including the target the build runs successfully with 213 tests
passing, 4 Ignored (as per the wiki page) and none fail. Looking at
the tests within the Visual Studio solution it seems like many of the
full set of tests are not being run by the build but I haven't
investigated any of the failing tests yet.

Using the resulting NSubstitute.dll in a Silverlight Unit Test project
seems to be working at a superficial level for me now.

David Tchepak

unread,
Feb 2, 2012, 9:29:46 AM2/2/12
to nsubs...@googlegroups.com
Hi Martin,

Sorry for the delay in responding to you. For some reason Google Groups didn't send a notification of your post awaiting moderation. 

Thanks for taking the time to look in to this. I wasn't sure how to make the build more tolerant of different SL40 patch releases; I'll give it a go! I'll also fix my stuff up in the ToArray() method.

The Rakefile should still build if you call 'rake target="SL40"'; omitting from line 13 should just stop it being build by default on the build server.

Regards,
David

David Tchepak

unread,
Feb 2, 2012, 9:46:22 AM2/2/12
to nsubs...@googlegroups.com
Ah, just found what you meant about the rake targets. Fixing now, thanks!

David Tchepak

unread,
Feb 2, 2012, 10:27:31 AM2/2/12
to nsubs...@googlegroups.com

David Burela

unread,
Feb 7, 2012, 1:00:53 AM2/7/12
to nsubs...@googlegroups.com
How long until the Silverlight support gets pushed out to Nuget?

-David Burela

David Tchepak

unread,
Feb 7, 2012, 1:23:39 AM2/7/12
to nsubs...@googlegroups.com
The main thing holding up an SL release is that I don't work with SL, so I'm concerned about pushing out a build which breaks for people using it with SL due to me being unable to test it adequately. 

I guess I'm really after someone who can vouch for it and is happy to be a bit of a caretaker for it, as in:

* Someone to run an SL build through its paces.
* Someone to check the current test coverage for SL so I've got some confidence that I can trust the tests to tell me if it's shippable.
* Someone who is going to use it regularly and is happy to raise issues for me (I'm happy to fix any issues if I've got a repro, although patches are welcome :))
Reply all
Reply to author
Forward
0 new messages