I’m Eric Tummers, Technical Consultant at Valid, and this is how I work

me and big chick
Eric Tummers likes challenges and sharing the solutions with others. His work is focused on the Microsoft .NET framework. He writes unit tests when he develops. Not all developers he has worked with share this necessity for unit tests and he has made it his task to convince them otherwise.
For 2014 Eric hopes to participate in a big Windows Azure project. That would give him enough to write about on his blog. We’ll see what comes his way.

Location: Sittard, NL
Current Gig: Technical Consultant, Valid
Word that best describes how you work: unittesting.
Current mobile device: iPhone 5
Current computer: HP Probook 6570b

What apps/software/tools can’t you live without? Why?

As a Microsoft developer I can’t work without Visual Studio. Recently we started using http://visualstudio.com for our projects, before we used on-premise Team Foundation Server. I like that SAAS (Software as a service) takes the sting out of staying up-to-date.

The entire family of Evernote (clipper, clearly, iPhone app) Since last november I’m a premium user to keep me from running out of upload allowance. I log interesting articles, emails I need to hold on to and scan most of the paper that comes in.

iSmoothrun is my preferred activity tracking app. My recent half marathon is a result of the history of captured data. Just logs everything I want and syncs with other online services like runkeeper.

What’s your workspace setup like?

Work setup

Work setup

Docking station with external monitor, keyboard and mouse. Powers my laptop (I don’t even carry my adapter in the bag anymore)

As a consultant I’m mostly on the go and this is a flex desk, so no papers laying around.

Good coffee is a must.

Home setup

Home setup

At home I have a wireless keyboard / mouse setup. The laptop is tilted and raised for better viewing. This is where my power adapter lives.

More clutter here, but I don’t mind.

What’s your best time-saving shortcut/life hack?

Avoid traffic by starting early. Also gives you a good hour of silent working before everybody gets in screaming about the horrible commute.

What’s your favorite to-do list manager?

Actually I use different to-do lists for my tasks. I use Trello for daily taskboard and for projects. Wunderlist for recurring tasks/chores like clean the sink or check the fire alarm. For longer running tasks, or tasks with content/documents The Secret Weapon in Evernote.

Besides your phone and computer, what gadget can’t you live without and why?

My Apple TV2 (jailbroken) hooked up to my NAS for movies and series. Also hooked to my stereo for music streaming. Awesome device!

What everyday thing are you better at than everyone else? What’s your secret?

Unit testing. Is that an everyday thing? Yes. The advantage of unit testing is the work it saves in the end. But you’ll have to put in the extra work in the beginning. With my experience from other projects I think “How can I unit test this” every time I program something. Reviewing code from others gives me great ideas how to do things better.

What do you listen to while you work?

When everything is working out like planned, silence is the working sound I prefer. But when the sh*t hits the fan: I’m a drum-and-bass fan. My latest powersong is also my ringtone: Run riot by Camo & Krooked.
run riot on soundcloud

What’s your sleep routine like?

My alarm clock is set to 7 AM when I’m working from home, to beat traffic it is set to 6 AM. When I wake before that my day is great. Also in the weekends I tend to get up as soon as I awake and it’s light outside.

Fill in the blank: I’d love to see _________ answer these same questions.

Have to go with Scott Hanselman. He’s the guy that gets 27 hours out of a day.

What’s the best advice you’ve ever received?

someecards.com - Make a shit first draft you cannot edit a blank page
I believe this is a variant on a Hemingway quote.

Original idea from Lifehacker.com.

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

Allow only release build to be published

We have a WPF application that we distribute with click-once deployment. The update feature is exactly what we need for our product. Getting the new build from Development into Production is easy, just publish.

The problem is that we only want Release builds to be published. Config transformation, code optimisation and custom icons are some of the main reasons we want to publish a Release build. Sometimes we forget to change the configuration and a Debug build is released into the wild.

As a safety net we added the BeforePublish build target to the project.

<Target Name="BeforePublish">
    <Error Condition="'$(Configuration)'!='Release'" 
           Text="Only Release build can be published" />
</Target>

Now when we try to publish without setting the configuration to Release the build fails.

publish.debug.fails

Since this is a very small project we haven’t setup automated build. The errors should keep us safe for now.

Posted in Development | Tagged , , | Leave a comment

Version store out of memory

In our current project we use Sql Server Data Tools (sqlproj) to put our database in source control. Recently we experienced random exceptions during loading and building the solution with multiple sql projects.

EsentVersionStoreOutOfMemoryException

Last week our builds started to fail. The logging showed something like

MSB4018: The “SqlBuildTask” task failed unexpectedly.
Microsoft.Isam.Esent.Interop.EsentVersionStoreOutOfMemoryException: Version store out of memory (cleanup already attempted)

On Microsoft Connect we found a workaround. By adding commandline option /p:CmdLineInMemoryStorage=TRUE the build worked again. Seems there is someone working at Microsoft with a great name ;) microsoft.connect.eric.msft

Posted in Development | Tagged , , , | Leave a comment

AngularJs and special characters from json webservice

My current project creates a Single Page Application (SPA) using ASP.NET MVC and AngularJs with data from ASP.NET MVC webapi REST webservices. With the buzzwords out of the way, let me describe the issue we had.

Some data from the webservice contains strings with special characters like “COÖRPERATIE” (dutch). After binding the json data with curly braces the webpage would show malformed strings like “COÃ-RPERATIE”.

Image courtesy of Kittikun Atsawintarangkul / FreeDigitalPhotos.net
Image courtesy of Kittikun Atsawintarangkul / FreeDigitalPhotos.net

We started looking for a solution with ngSanitize. Google gave lots of answers, but none helped. We tried filters, no chocolate. HTML escaping. The horror!

Right after the $http.get we added a $log of the string and found that it already was wrong. But Fiddler said it was correct? Seems to be a header you can send in the request: Accept-Charset: UTF-16

We added the extra header to our request and it worked. No more gibberish. The code samples below add the header to requests.

// client script angular
$http.get(url, headers : { 'Accept-Charset' : 'utf-16' })
     .then(function(response) { });
// client csharp code
var client = new System.Net.WebClient();
client.Headers.Add("Accept-Charset", "utf-16");

Since we always want to return UTF16 we made it the default response over UTF8. With the code below the webservice is configured to use the UTF16 encoding for the json formatter.

// add to global.asax or startup.cs
var utf8json = GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedEncodings[0];
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedEncodings.Add(utf8json);
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedEncodings.RemoveAt(0);

The webservice can stil return UTF8 but the client must explicitly request it.

Posted in Development | Tagged , | Leave a comment

Create Loadtest repository

Sometimes I clean up / remove / uninstall to much. During spring cleaning I uninstalled some localdb versions because I have a full SQL Server installation already. After some time I noticed my loadtest in Visual Studio would not start. Apparently I was using localdb for the repository database.

First create a new LoadTest2010 database with the script loadtestresultsrepository.sql. See How to: Create a Load Test Results Repository Using SQL

To change the connectionstring go to Manage Test Controllers in the LOAD TEST menu of Visual Studio. There is the Load test results store.

loadtest.repository.connectionstring

Everything is operational again, until my next cleanup.

 

Posted in Uncategorized | Leave a comment

Be careful when using mocked repository

One of the software development best practices is to use interfaces and dependency injection. But be careful when using a mocked version of your repository.

With FakeDbSet an InMemory IDbSet can be created for unit testing purposes. During setup you’d add the records and the test will simply use those records. But there is a small difference with the actual Entity Framework implementation used with most applications: reading from the database will result in a new object.

The properties of the object will be the same, no matter how often you’d get it, but it is a new object. During integration testing I noticed some strange behaviour due to this. Changes made to the object by my business logic would disappear.

Extra utils used are the Fakes generated by Visual Studio and the Copy extension from github. In my code I changed the setup of the test repository to mimic this behaviour:

private IRepository CreateFakeRepository(object[] records) {
   var fakeRepository = new Fakes.StubIRepository();
   fakeRepository.RecordsGet = () => {
      var fakeDataSet = new FakeDbSet.InMemoryDbSet(true);
      foreach (var record in records) {
         fakeDataSet.Add(record.Copy());
      }
      return fakeDataSet;
   };
   return fakeRepository;
}

After this half (!) my unit tests turned red. Fixing it took some time, but I’m more confident about the business logic now.

Posted in Test | Tagged , , , , , | Leave a comment

Lync for mac crash

After working for several months Lync for mac kept crashing on startup. No warning, no provocation, no survivors. The only way to stop the endless reporting is to uncheck the “restart Microsoft Lync” box.

Lync for mac Error

Upon further investigation I noticed a line in the console.

12/05/16 09:50:33,161 Microsoft Error Reporting[525]: 6   Microsoft Error Reporting           0x00003678 Microsoft Error Reporting + 9848
...
12/05/16 09:50:33,906 ReportCrash[526]: Saved crash report for EpocCamEngine[521] version 1.4 to /Users/Eric/Library/Logs/DiagnosticReports/EpocCamEngine_2016-05-12-095033_MacBook-Pro.crash

I remember installing EpocCam beta drivers and playing with it. This is done with a .pkg file I double click and let install. But how to uninstall? There seems to be no app for that, but a terminal statement.

pkgutil -—pkgs

Output contained the lines below.

...
com.kinoni.epoccam.EpocCamEngine.pkg
com.kinoni.epoccam.libavcodec.pkg
com.kinoni.epoccam.libavutil.pkg
com.kinoni.epoccam.libswscale.pkg
com.kinoni.epoccam.SoftVDigX.pkg
com.kinoni.epoccam.UninstallEpocCam.pkg
...

The last line (UninstallEpocCam) caught my attention. There was an app for uninstall?

uninstall epoccam with alfred

😳 All is well after this …

Posted in Tooling | Tagged , , , , , | Leave a comment

Loadtesting with Powershell

powershellOur product is in the acceptance testing phase. In the assigned environment the available tooling is very limited. But we must do a loadtest to report on the average requests / second our webservice can handle from a single client. Lucky for us we have access to powershell, but it is version 2.0.

The Invoke-RestMethod cmdlet is available from version 3.0 and up. I’ll have to write my own to use it in version 2.0. Below is my “implementation”.

function Invoke-RestMethod {
    [cmdletbinding()]
    param ([string] $url)    
    Write-Verbose $url
    $client = New-Object System.Net.WebClient
    $client.DownloadString($url)
}

We created a loadtest method that reads a csv-file and calls the Invoke-RestMethod with every record. A simplified version of this loadtest method is listed below.

function LoadTest {
    [cmdletbinding()]
    param()
    [System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
    # this reads 10000 unique id-s
    $testdata = Import-CSV 'C:\loadtest\data.csv'
    $template = "http://srv01/api/information/1/{0}/{1}"
    foreach($record in $testdata) {
        # call webservice
        $request = [System.String]::Format($template, $record.Id, $record.Name)
        $response = Invoke-RestMethod $request
    }
}

Now to measure the time needed to process the 10000 records we use the Measure-Command. The output tells us the time needed to process 10000 records, so divide 10000 by the seconds needed and we have the requests per second.

Measure-Command { LoadTest }

My preferred tool for loadtesting is Visual Studio, but when not available Powershell is the next best thing.

References

Powershell version 2.0 cmdlets, list of cmdlets available in Windows Powershell version 2.0.

Posted in Test | Tagged , , | Leave a comment