GithubHelp home page GithubHelp logo

Comments (18)

dennisdoomen avatar dennisdoomen commented on May 18, 2024 2

I've just tried a Windows Store 8.1 unit test project from inside Visual Studio 2013 using the NuGet package for FA 2.1 and it just worked. One thing that surprised me is that you are using R# 8. Only R# 8.1 supports Visual Studio 2013.

Oh, and to test async methods, rewrite your action like this:

Func<Task> asyncFunction = async () => { await matchWorker.GetMatchAsync(string.Empty); };  

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

No, it's just that FA is referencing the v11 version of that assembly. Officially it doesn't support Windows 8.1 apps yet. I'll need to see if I can dynamic loading like I do with the full .NET versions.

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

Uhm, I've always thought that Visual Studio 2013 will install the same binaries on Windows 8(.1) as on Windows 7.

According to http://www.jetbrains.com/resharper/download/

ReSharper 8 officially supports Visual Studio 2013, 2012, 2010, 2008 SP1, and 2005 SP1.

I've been using ReSharper 8 since the very first Preview of 2013 (Visual Studio 11 Developer Preview).

There is no difference if I write my action like

Action action = async () => await matchWorker.GetMatchAsync(string.Empty);

or

Action action = async () => { await matchWorker.GetMatchAsync(string.Empty); };

both fail when I run the tests either through R# or through NUnit.

The fun thing is: I've already managed to test Exceptions in the very same project as the one where my MatchWorker is, though I got the same FileNotFoundException every time I messed something up, i.e. an Assertion error.

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

So I was wrong about R#. However you must definitely cannot create Windows 8.1 apps on Windows 7. That's why I cannot really upgrade FA to fully support WinRT 8.1. I would need to use two version of Visual Studio at the same time. 2012 only targets WinRT 8.0, whereas 2013 only targets WinRT 8.1.

So are you using Win8 or Win7?

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

I'm on Windows 8.1 on three different machines :)

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

Me too. So if you will, can you try something for me?

  1. Start Visual Studio 2013 RTM
  2. Create a Windows 8.1 Store Unit Test Project
  3. Add a reference to the FA Nuget package
  4. Create a single unit test that used an Action that throws and the ShouldThrow method
  5. Verify that it fails with the usual reporting rather than your FileNotFoundException

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

Worked as intended. Actually, this is the first time I see human readable error messages :S

Is it a combination of me using NUnit and a regular Windows Store 8.1 Library instead of a Unit Test Library (which uses MSTest)?

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

Ah, now I'm getting it. Your using a WinRT version of NUnit? I didn't account for that. In fact, I assumed everybody uses MSTest when building Windows Store apps.

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

Well, I initially wanted to use MSTest but then I had to switch over to NUnit because of FakeItEasy =) Couldn't find any good Mocking Framework that also worked for Portable Class Libraries and Windows Store Apps.

At the moment I don't even know why I assumed that I need NUnit in order to use FakeItEasy - I've read that some people on StackOverflow (who are having problems :D) are using FakeItEasy with MSTest. So maybe it's time for me to switch the testing framework as well if it's working :D The still sad thing is that the NuGet package is not yet configured to support WinRT though it's working fine if you add the reference manually.

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

Now I'm confused. Is your class library a Portable Class Library? Because I'm 100% sure FakeItEasy doesn't runder under the Windows Store run-time.

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

I'm using FakeItEasy with Portable Class Libraries and with Windows Store 8.1 Libraries without any problems. I believe I added the SL version as reference.

develop__versus_whitelabel_ debugany_cpu _-_microsoft_visual_studio_2013-12-17_15-40-24

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

The screenshot shows the project that contains the code to test, but can you provide me with a similar screenshot for the actual project that is using FakeItEasy, NUnit and FluentAssertions? I just created a PCL that targeted .NET 4.5 and Windows Store and everything worked as expected.

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

My PCL (VERSUS.Test.Mockable) contains a few base-classes that use FakeItEasy which are used in my Windows Store App Tests (VERSUS.Data.Test etc.).

At the moment there are no dedicated tests yet for my PCL project (not sure if I'll ever need one), NUnit is just referenced to mark the said base classes as Test class so I don't need to do that in the derived classes.

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

So VERSUS.Data.Test is a real Windows Store Unit Test library? Because FakeItEasy will most definitely not work under the Windows Store runtime.

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

Uhm, works for me :S

I've downloaded FakeItEasy in a simple .NET Console Application to get all assemblies, copied them to my Windows Store Library, added a reference to the SL40 assembly, added NUnit via NuGet --> Works!

windowsstoretest_ debugany_cpu _-_microsoft_visual_studio_2013-12-18_14-31-51

Should I upload the whole test project as well?

Ninja-Edit The source code is available at https://bitbucket.org/cH40zLord/windows-store-test-with-fakeiteasy-and-nunit/overview (would have been better if I created a GitHub repo for that, huh? Didn't want to upload/commit a testing project as my first GitHub project :P I'd rather have a real project on GitHub instead of this... :D)

from fluentassertions.

keichinger avatar keichinger commented on May 18, 2024

Surprise! I've managed to reproduce the error in the test project!

An IOException is thrown every time you throw an Exception in an async method.

master__windowsstoretest_ debugany_cpu _-_microsoft_visual_studio_2013-12-18_16-30-13

I've updated the code on Bitbucket

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

So I managed to reproduce it with the project from Bitbucket. However, async specs should use the following syntax:

Func<Task> action = async () => { await subject.ExceptionsInAsyncMethodsCrashFluentAssertionsInWinRT(string.Empty); };

Then the spec succeeds. But the problem is really with finding the unit test framework assembly to throw the correct exception type. Now investigating...

from fluentassertions.

dennisdoomen avatar dennisdoomen commented on May 18, 2024

Fixed it in the latest commit. I now added automatic detection of the PCL version of NUnit. If that's not available, it'll fall back to the MSTest framework.

from fluentassertions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.