Monday, 14 November 2016

xUnit Theory test ClassData with complex type

xUnit.net is a powerful, free, open source, unit testing tool for the .NET Framework. xUnit uses different notation to NUnit or MSUnit to specify test with parameters. Here I am going to show how to use Theory ClassData with complex type.

I have a sample class Plant, which has function 'bool IsEqual(Plant plant);'. We will create a Theory test for it.
[Theory] [ClassData(typeof(IsEqualTestData))] public void IsEqual(Plant plant1, Plant plant2, bool expectedResult) { Assert.Equal(expectedResult, plant1.IsEqual(plant2)); }
Class IsEqualTestData is a ClassData used with complex type Plant. It generates a list of arrays of 3 objects Plant1, Plant2, and ExpectedResult boolean.
private class IsEqualTestData : IEnumerable<object[]> { private readonly List<object[]> _data = new List<object[]> { new object[] { new Plant() { Name = PlantTester.PlantName1, Description = PlantTester.PlantDescription1 }, new Plant() { Name = PlantTester.PlantName2, Description = PlantTester.PlantDescription2 }, false }, new object[] { new Plant() { Name = PlantTester.PlantName1 }, new Plant() { Name = PlantTester.PlantName1 }, true }, new object[] { new Plant() { Name = PlantTester.PlantName1, Description = PlantTester.PlantDescription1 }, new Plant() { Name = PlantTester.PlantName2, Description = PlantTester.PlantDescription1 }, true } }; public IEnumerator<object[]> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } }
When running in xUnit it will report result of running each entry in the test.

If you are using Visual Studio you can download snippet file from github repository.

Reference:

xUnit_ClassData.snippet
Using dotnet watch test for continuous testing with .NET Core and XUnit.net - Scott Hanselman

Tuesday, 5 July 2016

.Net Core 1.0 Released! Or installing .Net Core on Debian

This was a great news to me that .Net Core 1.0 was released. I already was trying .Net Core RC2 on my Debian 8.x so I prepared to go through the installation process of new release. Surprisingly installation of .Net Core 1.0 described in Install for Debian 8 on Microsoft site was very smooth in comparison to beta versions. All I had to do is to clean up my previous install from ~/.dotnet go through the instructions on install page and "Hello World!" programs runs. Very pleased to see that improvement.

So here I am going to provide some links to what to do next once you get your install done too.

References:





Sunday, 26 June 2016

Recording Music CDs under Win 7


From days of Windows 95, Windows 98, Windows XP CD/DVD burners and writers were only coming out on the market and computer users were required to install additional software, which will allow them to burn CD and DVD disks. Disk writing software like Nero was included for free with the CD/DVD burner you could buy for your desktop computer or included on new laptop. Modern Windows operating system like Windows 7, Vista, Windows 8 and Windows 10 already have built in support for burning CD / DVD music, data and video disks. Users can use included Windows Media Player to rip and burn music CDs.

Under Windows 7 to burn audio CDs insert CD disk in disk drive and in Windows Media Player open Burn tab, drag music files you want to burn. The blue bar shows how much space left on the disk. Once files are selected click Start burn to start recording on the disk.


Data CDs / DVDs can be burned directly from Windows Explorer. Disk image files with ISO extension can be burned using right mouse click on the file and selecting "Burn disk image".

If you still require more features than the basic functions to burn disks look through available free and commercial applications available on sites like filehippo

References:




Sunday, 24 January 2016

Install NVidia Graphic Drivers on ASUS ROG G750JW

ASUS ROG G750JW comes with GEFORCE GTX NVidia 2GB graphic card. To get a full power of this card on Debian we need to install nvidia drivers for it. Debian Wiki NvidiaGraphicsDrivers article describes several ways to do it. Here I am going to summarise the steps that worked for me.
  1. Add SteamOS repository to /etc/apt/sources.list.d/steamos.list, for example:
  2. deb http://repo.steampowered.com/steamos brewmaster main contrib non-free
  3. Update the list of available packages. Install the appropriate nvidia driver and related packages from SteamOS repository:
  4. # aptitude update
    # aptitude install -t brewmaster libegl1-nvidia:amd64 libgl1-nvidia-glx:amd64 libgl1-nvidia-glx:i386 libgl1-nvidia-glx-i386 libgles1-nvidia:amd64 libgles2-nvidia:amd64 libnvidia-eglcore:amd64 libnvidia-ml1:amd64 libxnvctrl0 nvidia-alternative nvidia-driver nvidia-driver-bin nvidia-kernel-dkms nvidia-modprobe nvidia-settings nvidia-vdpau-driver:amd64 xserver-xorg-video-nvidia
This will also install the recommended nvidia-driver package. DKMS will build the nvidia module for your system. Restart your system to enable the nouveau blacklist.

References:


Tuesday, 10 November 2015

Debian 8 – Jessie - Enabling Wifi on ASUS ROG G750JW

Debian Jessie installer managed to detect most of hardware during install like LAN, sound and video, but WIFI had to be configured separately.
  1. Add a "non-free" component to /etc/apt/sources.list for your Debian version, for example:
    # Debian 8 "Jessie"
    deb http://http.debian.net/debian/ jessie main contrib non-free
  2. Update the list of available packages. Install the relevant linux-headers.
    # apt-get update
    # apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms
  3. Unload conflicting modules:
    # modprobe -r b44 b43 b43legacy ssb brcmsmac
  4. Load wl module:
    # modprobe wl
  5. Edit /etc/network/interfaces and comment out or remove allow-hotplug eth0

References: