comments lut, live unit testing, vs2017, visual studio 2017 edit

Welcome to the Christmas Eve edition (December 24th, 2017) of of the inaugural C# Advent Calendar! Please go and check out the other 23 awesome posts in the series.

I hope you enjoy this post / find something useful from it, and then go forth and have a very Merry Christmas!

Live Unit Testing

You may be curious what “live unit testing” means, so let’s dive into that a little bit.

“Live” unit testing is simply the automated execution of unit tests that may have been impacted by a code change, and provides the results of that test run back into the IDE (in this case, Visual Studio) in real time.

There are products out there that have provided this mechanism for quite some time - most notably, NCrunch, which is a fantastic tool.

However, Microsoft has recently given us this capability directly inside the Visual Studio IDE, without the need for external tooling/extensions!

Live Unit Testing in Visual Studio

Before we get too far, let me preface this with a few caveats:

  1. You must be using Visual Studio 2017 Enterprise edition.
  2. The feature is only supported for C# and Visual Basic projects (Full .NET Framework, or .NET Core)
  3. Using one of three supported frameworks (of which a minimum version is required)

Since the first two bullets are pretty self-explanatory, let me provide some more information on #3.

The three supported frameworks, and their editions (as of this writing) are:

Framework Framework Minimum Version Adapter Minimum Version
MSTest MSTest.TestFramework 1.05.preview MSTest.TestAdapter 1.1.4-preview
NUnit NUnit 3.5.0 NUnit3TestAdapter 3.5.1
xUnit xUnit 1.9.2 xUnit.Runner.VisualStudio 2.2.0-beta3-build1187

If you’re using a different framework, or not currently using one of the specified versions of that framework - you’re going to miss out on some sweet, sweet, testing.

To configure the Live Unit Testing feature, you can find the settings in Tools | Options | Live Unit Testing:

Live Unit Testing Settings Dialog

The new Microsoft docs platform has a great entry describing each of the settings on this dialog, which you can find at https://docs.microsoft.com/en-us/visualstudio/test/live-unit-testing

Example Time!

In this first screenshot, I have a very simple extension setup to convert a string to a possible boolean. However, take note of the blue lines to the left of each line of code.

Code with no tests

The line tells us that it isn’t covered by a corresponding unit test, so let’s add one!

Here you can see a very (very) simple test checking our “true” condition of our extension Test is passing!

And, now that our test is executing, we can go back to our extension code, and see that Live Unit Testing is now marking the line of code as covered AND passing! Sweet Code Coverage

Clicking the green check-mark will show you the test names of tests that execute that line of code: Cool!

If we introduce a test that fails (since a “false” string should return false), such as: Uh oh

Back over to our actual code, we’ll now see which lines of code are failing during that test: Not good

And, clicking the red X will show you the test names of tests that are currently failing: Ah, that's the one

Summary

Testing your code is great, but seeing it happen in real-time is pretty darn sweet. This feature is ever-evolving as well, as Microsoft has updated the feature a variety of times already since the initial release. Keep up to date over at https://docs.microsoft.com/en-us/visualstudio/test/live-unit-testing (and for even more information that I didn’t touch on - like test exclusions (an absolute necessity for integration tests))

Check out the 2017 C# Advent post for links to other great content!

Thanks for reading!


comments meta edit

This post is pretty meta, actually, but I found it a little too interesting not to publish.

When I decided to restart my blog, I wanted to use GitHub Pages / Jekyll. The problem with that is that I also have my own domain name, and I strongly believe in ‘HTTPS ALL TEH THINGS’ - which I could not do with GitHub Pages and a custom domain.

I knew there had to be a way to accomplish my very simple requirements:

  • Jekyll
  • HTTPS/TLS
  • No GitHub

Eventually, I came to the realization that all I really needed was a Linux VM, and some coffee.

My first starting point was Azure, cause I’m a Microsoft-stack kind of guy, but the price of the Linux VM that also allowed custom domains and HTTPs was over $50 USD/month. I ain’t spending that on a blog. Then, I remember my old friend, Digital Ocean. I knew I could spin up a low-end, but still enough for a blog, VM for about $10 USD/month, which I was much more comfortable with.

So, I signed back up, and fired up a basic Linux VM.

With the VM ready, I just had to figure out the configuration for everything -

  • Ruby
  • Jekyll
  • Git (plus some way of building the site when I pushed changes, ala, GitHub Pages)
  • Apache
  • Let’s Encrypt

Since I’m not a Linux guy, this took me about 4 hours to figure out. Every article I referenced did things a little bit differently than the last, and nothing worked for me. I ended up blowing away the VM at least 3-4 times.

Finally, after multiple attempts, I landed on the right set of apt-get installations and configuration changes to get all of this going again.

Before I dive into the configuration settings and walk-through, here is an overview of my blogging process, in graphical form:

blogging process overview

It all starts with me, the blue guy in the upper left corner. I make a post, and push it to my private Git repository hosted on my Linux VM from Digital Ocean. The Git repository has a post-receive hook that clones the repository into a temporary location, does all the Jekyll magic, pushes the files into the Apache folder for the site, and then cleans up after itself. The site in Apache is visible to the internet, and bound to a Let’s Encrypt certificate that auto-renews daily via a cron job.

You can also see an alternate path, where I can push the code to GitHub. This is to allow anyone to fork/clone the repository (so they can start a similar site, or maybe push a change to mine). If they decide to push a change to mine, I can integrate the change locally, and then push it to the private site.

I really like this setup (now that it’s all setup and configured the way I want/need it to be)

In the next post, I’ll begin outlining the steps I took on the Linux VM to make the magic happen.


comments meta edit

I’m back!

Not that you care, but still.

Content forthcoming!

Thanks for reading!


comments itunes, letsencrypt, podcast edit

For all of you podcasters out there, Apple has FINALLY enabled support for LetsEncrypt certificates to be used on your podcast feeds. I only recently ran into this issue standing up a new feed for The Talking Devs, and getting denied by the iTunes submit process (but accepted right away via Googles).

Apparently, this change also happened somewhat silently, and currently they (Apple) haven’t even updated their FAQ on the changes.

I learned about this via a friend, that pointed me to this article: https://feed.press/blog/2016/12/16/apple-silently-adds-support-lets-encrypt-certificates-podcast-feeds/


comments extensions, visual studio edit

Every single time I install Visual Studio, the very next step I take is to install my favorite extensions. I only have three, and here they are, in order:

  • ReSharper - I can’t live without this anymore. I’m finally to the point where I have a lot of shortcuts memorized. VS is catching up, but R# still takes the win.
  • NCrunch - Continuous testing, right in VS. Love my green dots.
  • WallabyJs - Continuous JAVASCRIPT testing, right in VS. Love my green squares :D

Pretty simple list, eh?

What about you? What are your favorite extensions? Is there something groundbreaking that I’m missing out on? Something you developed yourself? Leave it in the comments!

*Also, props to WallabyJs for being the only one in my list WITH HTTPS, BY DEFAULT.


comments extensions, visual studio, notepad++, oss edit

The past weekend, I took a few moments to relish in the “fun” that is programming something that is not work-related. That creation came to be a Visual Studio extension, known as, “Open in Notepad++”.

You might be wondering, what does this extension even do?

Well, it adds a new item to the context menu when right-clicking files/folders in the Solution Explorer:

Context Menu

The extension will attempt to find your installation of Notepad++, but if for some reason it cannot, you can always manually update the path in Tools | Open in Notepad++:

Settings Pane

You can install this extension through the Extensions and Updates dialog inside of Visual Studio:

Install Dialog

Or, grab the VSIX directly from the Visual Studio Gallery (also, go here to leave awesome reviews for me): https://visualstudiogallery.msdn.microsoft.com/4f30cefe-1ca0-4b71-9ec8-03c6ef1114c3

Also, if you find any issues, or want to contribute, head over to GitHub: https://github.com/CalvinAllen/open-in-notepad-plus-plus

Thanks!


comments python, drm, google edit

I purchase all of my music through Google Play, and I primarily use their web application to listen to it. As a precaution, I also use the Music Manager application to keep a local backup of all of this music on my NAS.

Recently, I wanted to switch to a new Google Account because I was changing primary email addresses. Before doing this, I made sure the music manager had downloaded any purchased music to my NAS because I will be deleting the old Google Account permanently.

Once I had verified the music had been downloaded, I logged out in the Music Manager application, and logged in under my new account. At this point, I had to wait for ALL of my music to be re-uploaded to Google’s servers.

After the music had uploaded, there were 17 songs that could not be uploaded because I had purchased them under a different account. (Apparently not of all the music contains DRM?)

You can see the error in the troubleshooter –

“Song was purchased with another Google Play account”

A little digging led me understand that Google hides their DRM in a hidden ID3 tag that is not easily removable by conventional means. This digging, however, also led me to a Python utility that could do it – and so, into the world of Python.

First, I had to install Python, which was dead easy – https://www.python.org/downloads/ *Note: I am on a Windows machine, and the utility I will show you apparently requires version 2.7 of Python, so get that one :)

During the installation, I let the installer add python.exe to my PATH variable.

Once the installation was complete, I launched a command prompt and installed ‘eyeD3‘ using pip:

eyeD3-install

Now, navigate to your music directory (mine is on my NAS, mapped to my computer as “M:”)

cd /d M:

Execute one simple command, and let it run (depending on how much music you have, it could take a while)

python -m eyed3.main --remove-frame PRIV ./

You should now see a lot of text flowing through your console output. That’s eyeD3 doing its thing. Let it run. Go grab a snack.

Once completed, the Google Music Manager picked up on the fact that the files had changed on disk, and started to re-upload them – without error I might add!


comments career, meta edit

I realized earlier that today marks my one year anniversary at Heuristic Solutions (thanks, Facebook ‘On this day’ :-) ).

My time at Heuristics has definitely been a game changer for me. Being able to work alongside Seth Petry-Johnson and Matthew Groves has proved beneficial beyond my imagination. To say, “I’ve learned a lot”, would be an oversimplification of the amount of knowledge I’ve gained over the past year, but that’s the easiest way to put it – I truly have learned a lot.

What does the next year hold?

Hard to say for sure. I would imagine a ton of new lines of code for LearningBuilder and more learnin’.

Outside of that, surprise me.


comments blogging, career, review edit

Over the last few weeks, I’ve been indulging in the content delivered to my inbox by a Mr. John Sonmez.

This content, or what is better known as his 5 day email course on blogging, has been a delight to consume. If you’ve never blogged before, but have always wanted to, I suggest you subscribe to John’s email course. He provides a clear and concise path for potential bloggers to get started easily and quickly that I haven’t found in other blogging materials.

For me, personally, since I’m already somewhat of a blogger, it’s provided a ton of ideas that I plan to work through and implement here.

To close, GO SIGNUP FOR THE COURSE!


comments conference, review, codemash edit

I’ve known about CodeMash for about 3 years, and of those three years, I had to skip out on TWO of them. The first year had already sold out before I found out, so there wasn’t much I could do in that situation. The second year, our daughter was born one week before (which I obviously knew ahead of time), so I couldn’t go then either.

Finally, with no children being expected, plenty of forewarning, and a ticket paid for by my [awesome] company, Heuristic Solutions (hey, we’re hiring), I was able to attend!

I didn’t end up attending any of the pre-compilers, only the main two days of sessions.

Let’s get to it!

Day One

Ten Practical Tips for Automated Testing of Web Applications - Jim Holmes

Jim is an experienced tester, and a great speaker – so this is a fantastic session for anyone interested in testing (obviously).

I walked away with some good tips, and a testing framework that I hadn’t heard of before.

The Future of C# is Now! - Dustin Campbell

I went into this session expecting an overview of new C# features, and I got that.

However, Dustin was also showing off a code analyzer that he built using Roslyn that included fixes for migration pre-C# 6.0 code to C# 6.0.

My love for Roslyn begins.

Decoupling the Frontend through Modular CSS - Julie Cameron

I am the furthest thing from a front-end designer as you can get, but I do have to think about stuff like it on a daily basis.

I, more or less, went to this session by recommendation, and I’m actually glad I did.

Julie gave some great tips for structuring your HTML, CSS, & JavaScript that I hadn’t paid much attention to before. She also went over some conventions that I had never even known about, so all in all, this was an excellent session.

Xamarin Forms and The Future of Mobile Application Development - Jesse Liberty

This was one of the vendor sessions, but since it was being presented by Jesse Liberty, I had to go. I tend to enjoy his style of teaching (I think I’ve watched every single one of his Pluralsight courses :))

Not only that, but Xamarin Forms is on my radar of things to deep dive, so I figured this would be a great session.

I was let down a little bit, to be honest. It was very introductory to what Xamarin Forms is and the basics on how to use it. I expected somewhat of a deeper look into it.

Still a good session, if that’s what you’re looking for.

Building Code Aware Frameworks using the .NET Compiler Platform (“Roslyn”) - Kevin Pilch-Bisson

As you previously read, I have fallen in love with Roslyn, and couldn’t pass up the opportunity to sit on a session dedicated to it.

Ironically, I had received the latest MSDN magazine in the mail prior to leaving for CodeMash, and had brought it along to read (which I did). This session demonstrated the concepts and sample code from one of the articles in that issue.

It was still a great session, and just the conversation and questions that went on were worth it.

Day Two

Getting More Out of Git - Jordan Kasper

I was a little late to this session – hey, it was early, alright! – and it was packed, so I ended up sitting in the floor. Comfy.

Anyway, there were a lot of good tips packed into this session, and Jordan did a great job of presenting. For me, though, I wish it had been later in the day, because I might have zoned out a time or two. Maybe. Probably. Yeah, I did.

Clean Code: Writing for Humans - Cory House

I’ve been following Cory for a while now, and was actually able to meet him and see his session while at CodeMash. Cory is an awesome guy, super cool, super nice, and gives a great session on clean code to boot.

The funny thing about this session, is, you listen to it, nodding your head the whole time agreeing with everything he says. Something about the material being reiterated to you in a fantastic presentation really makes the session worth it.

From Backbone to Ember and Back(bone) Again - Jonathan Knapp

I wasn’t fond of this session, mainly because it outlined a contracting gig where they did exactly what the title says. It didn’t hit home with me because I’ve never used either of those frameworks (and likely won’t for some time). Jonathan gave some metrics as to LOC/Speed/etc difference between the two, which was nice to see – but then ended up picking the slower/bigger one, and I don’t quite understand why. The whole time he kept reiterating that the original developers didn’t know JavaScript, and I suppose that’s a fair reasoning for being there, I think I expected more of why I should choose one of these frameworks over another – and, unfortunately, I still don’t have that answer.

Do You Even Kanban? - David Neal

This was another vendor session, and quite honestly, I was a little let down with it.

What I thought would be a session with a lot of information on LeanKit, it turned out to be an introduction to Kanban.

I already Kanban.

OPEN SESSION: Roslyn

Guys, this was awesome (as are most open sessions).

This open session was packed, with people such as:

  • Kevin Pilch-Bisson
  • Dustin Campbell
  • Jon Skeet
  • Tim Rayburn
  • Kathleen Dollard

If you don’t know who those people are, go find out. NOW.

I didn’t contribute much to the overall conversation, but listening to these industry leaders talk about Roslyn made my day. I followed along with most of it (some definitely went over my head).

You can have your movie star idols – some of mine are listed right here. It was very difficult to choose those sessions, there were a ton of options for every time slot, and you want to see them all!

Conclusion

To summarize:

  • CodeMash is awesome.
  • The people that attend CodeMash are awesome.
  • The sessions are awesome.
  • The food is awesome.
  • Meeting new people is awesome.

Get your ticket and attend next time – find me and say hello, cause you better believe I’m going back next year!