Use Double loop TDD in Core 1.0 part II

After  some problems with double loop TDD it is time to some more errors.

As I mentioned in previous post with double loop TDD I created test project with BDD tests written in BDDfy. When I tried to compile the solution I realize that I do not add a reference to the tested project based on Core 1.0 template. And here problems comes, because Visual Studio do not let me to add this project reference. Incompatibility in .Net Framework versions 😉


Then I realize I must create special test project with compatible version to Core 1.0. Instead of choosing ‚Test + Class Library’ You have to pick up ‚Web + Class Library’ and do not worry about the above .NET Framework 4.6, the project will be created properly 🙂CreateTestProjectForWeb

Then I have added reference to existing template Core 1.0 project and try to build. Unfortunately Visual gave me dependency errors:


Then I came to EntityFramework official issue about adding EF to DLL project. Changes proposed in above issue not helped me solve dependency problem 🙁 I found out solution in xunit page’s note that in project.json I must change ‚dotnet5.4’ to ‚dnxcore50’. Then project builds properly, oh YES!

After all, to the test project, I moved classes created in part I of double loop TDD and then tried to build again. It occurs that both the Coypu and BDDfy do not have support to Core 1.0 RC1 and I must to let go with integration tests with that form.

Give a try to BDDfy for .NET

Last week I wanted to try to use Double TDD  approach, looking at Waldemar Mękal’s presentation on dotNetConf 2015th conference I saw that he uses BDD in his double TDD.

I decided to write some words about BDDfy which is the simplest BDD framework for .NET or so project creators wrote.

Behaviour-driven Development(BDD) is a software development process that emerged from test-driven development. Behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software development and management teams with shared tools and a shared process to collaborate on software development” wikipedia says.

I installed BDDfy via NuGet Console:
Install-Package TestStack.BDDfy

And write sample tests based on these requirements(mapped from Waldek presentation):
Given there are no companies
When I go to companies page
Then I see a text 'There are no companies loaded yet.'

Given there are defined companies
When I go to companies page
Then I see full list of defined companies

First requirement implementation using BDDfy fluent API:

public void NoCompaniesInTheSystem()
    new CompaniesTestsContext()
        .Given(c => c.ThereAreNoCompanies())
        .When(c => c.IGoToCompaniesPage())
        .Then(c => c.ISeeATextNoCompaniesLoadedYet())
        .TearDownWith(c => c.Dispose())

You can see that above test is self descriptive and describes behavior, which is the basis of BDD.

Second requirement implementation is very similar:

public void ManyCompaniesInTheSystem()
    new CompaniesTestsContext()
        .Given(c => c.ThereAreCompanies())
        .When(c => c.IGoToCompaniesPage())
        .Then(c => c.ISeeATextManyCompaniesLoaded())
        .TearDownWith(c => c.Dispose())

Both cases using CompaniesTestsContext class, which hides implementation details. This class contains mentioned by me in previous post helper classes Client(based on Coypu) and SystemUnderTest(based on Microsoft.DotNet.Hosting).

Use Double loop TDD in Core 1.0

Today I will try to reuse Double TDD approach taken from Waldemar Mękal’s presentation on dotNetConf 2015th conference.

What Double loop TDD is?
DoubleLoopTDDIt is TDD but is doubled 😀 I am just kidding 😉
It is adjusted to start writing new feature from failing acceptance test and then write in sequence unit tests with mocks and after each test pass replace mocks with proper impementation until acceptance test pass.

Waldek presented his sample with helper classes, SystemUnderTest and Client, which land in the Infrastructure folder. Client uses Coypu as UI tester browser, so I opened NuGet Package Console and:
Install-Package coypu

When implementing Client class Resharper gives me a hint(figure below) to use Null Propagation(?.) new C# 6.0 feature. So then I read something about it to not be a noob in this subject. In short: When you use ?. it will be converted into an in-line if-statement(read more details here).

Second part is SystemUnderTest, which uses Microsoft.DotNet.Hosting.WebHostBuilder(). Again NuGet Package Console:
Install-Package Microsoft.DotNet.Hosting

… and then many problems arises…

NuGet returns Logging warning and Concurrency error:
Install failed. Rolling back...
Package 'Microsoft.Extensions.Logging.1.0.0-rc1-final : Microsoft.Extensions.DependencyInjection.Abstractions [1.0.0-rc1-final, ), Microsoft.Extensions.Logging.Abstractions [1.0.0-rc1-final, )' does not exist in project 'FinData.Web.Tests'
Install-Package : Failed to add reference to 'System.Collections.Concurrent'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ Install-Package Microsoft.AspNet.Hosting -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

So I googled out and read something about gacutil.exe for registering *.dll in GAC.
Where to find gacutil? WIN -> Developer Command Prompt for VS20XX -> where gacutil
Gacutil localization depends from the framework version, but common part is: %systemDrive%\%ProgramFiles%\Microsoft SDKs\Windows\vX.XA\bin\NETFX X.X Tools\gacutil.exe

You do not need to know, where gacutil is. To add assembly to GAC just run Developer Command Prompt for VS with Administrative privileges and then run command: gacutil /i PathToDll.dll. Then console should give info: Assembly successfully added to the cache.

Yet another question: Where is it really installed? To What localization? When gacutil runs gives You info about own version, in my case Version 4.0.30319.0 says that most likely newly added *.dll comes to
But my test project has .NET Framework version 4.6, so this assembly addition to GAC was unsuccessfull. I must manually copy/paste assembly to ReferenceAssemblies localization, in my case
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6

Then I saw, that after successfull Hosting installation by NuGet I have a lot of stuff in packages folder. I do not like this.

After these problems I started to understand, why Waldemar Mękal told that he prefers to hold test files in the same project, which is tested. In some next post I describe, that above problems are just the beginning, but first I will take closer look at BDD approach, which was used in this presentation.

ASP.NET Core 1.0 First steps

In this week at last I installed Visual Studio 2015 on my computer.

Then I installed Asp.NET Core 1.0 RC1(Release Candidate 1), which was released in November 2015. According to the roadmap RTM(Ready To Manufacture) version should be available approximately Q3 2016.

I run Visual Studio and add new project ASP.NET 5 to my solution. I chose authentication as Individual User Accounts and after project creation let nuget restore many packages including EF7.

When I clicked to Debug my app on IIS Express, Visual opens browser with new page, but what is interesting in Visual I can see Diagnostic Tools bookmark:

Diagnostic Tools

It shows diagram of memory usage by process, when GarbageCollector runs, which generation, duration of run and if was forced/unforced(show it after mouse hover the yellow object). It also shows percentage of all processors usage. Cool!

Short description of project’s components is on docs asp dot net.

To run web page without using Visual Studio, then DNX(Microsoft .NET Execution Environment) must be used. It provides host process, CLR hosting logic and can run also other types of .NET apps.

More about DNX, DNU, DNVM and other ASP.NET names You can read there.

I have published my newly created website to Azure on financialdata azurewebsites net

Choosing project licence, is it really simple?

I have to admit, that I’ve never before think about choosing licence for my projects, but this time setting up new project on GitHub I decided to stay longer on choosing licences from given list(picture below). I have made this decision, because I wanted to learn sth new about differences in using many types of licences.


At the beggining I know, that my project has to be open source. GitHub created very helpfull page with great address choose a license dot com, where are expleined the differences between MIT, Apache 2.0 and GNU v3.0.

  • MIT – short liberal licence. It lets people do anything they want with your code as long as they provide attribution back to you and don’t hold you liable. Examples of usage: jQuery and .NET Core
  • Apache 2.0 – similar to MIT with difference, it provides an express grant of patent rights from contributors to users. Examples of usage: Apache, Swift and Android.
  • GNU v3.0 – requires anyone who distributes your code or a derivative work to make the source available under the same terms(read also open source in my case). Examples of usage: WordPress, Linux, and Bash

When licences are used there is need to attach copyright header at the beginning of the every source file included in the project. Content of the licence also should be included among project files.

This time I chose None licence (I think my choice was dictated by the fact, that I’m lazy), which is equivalent with choosing Public Domain licence. That’s mean everyone can change my code and apply it to own projects, but I do not have obligation to insert copyright headers to my code files 🙂

During project development I may change decision and choose other licence kind.

Let’s the party begin

Some time ago with my good friend I wrote an application, which uses financial data for Polish equity market. Unfortunatelly, as it comes to most of homemade projects, work on this project was suspended, before the project started to presented some value added. My friend let me to reuse part of this application in the competition Daj się poznać.

At the begining I am going to write about some little problems upon migration of existing project. I copyied project files from existing solution to newly created solution. Then problems occurs.

First of all NuGet compilation problem:

Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see The missing file is \.nuget\NuGet.targets.

One look at the packages folder(where NuGet downloads packages) and all packages were properly downloaded. One little question to „uncle google” gave me the answer from stackoverflow. After removing appropriate lines from *.csproj and repeated the operation on Test project, solution becames properly compile. JUUUUPI 🙂

I changed some class names and then next problem arise. Class name and the same namespace name bode problems, indeed. In this case when creating system under test in the test project there should be used code sth like this:
sut = new NewsService.NewsService(…)
That means there is a need to repeat name. I am not proud of it, but for now I have to leave it in that form.

And finally the last problem. I run unit tests and… FAIL. Auuuu… So it ends, when CI(Continuous Integraion) is not used in the project. Tests are run from time to time, instead of after every little code change. I must put effort to implement apps with TDD.

Problem with unit tests was due to use RhinoMocks IgnoreArguments() method. I also gave method parameters and of course parameters were ignored, a few minutes of life vanished 😉

Problems with app import solved. Keep fingers crossed for evolution of my project in the competition 🙂