Want to make unit testing easier? Check out Fluent Assertions. You can add this library to your C# Unit Tests in .NET Framework or .NET Core. To be clear, I’m just a fan of this library and I am not involved with it in any way.

Instead of assertions like these:

Assert.Equal(5, result.Count)

Assert.Equal(firstName, result)

Isn’t this better?

result.Count.Should().Be(5)

result.Should().Be(firstName)

But that’s just the start. There is plenty more to see. In this 5 Minute video, I’ll show you what you need to get started, it is really simple.

 

If you like this video, please subscribe to my YouTube Channel: youtube.com/schwammystreams

I’m getting really excited for TechBash 2019. Before you know it, we’ll have loads of developers descend on the Poconos to learn, network, and have fun! I figured I would compile a list of some of the great reasons to attend TechBash. If you are on the fence, I think this will do the trick!

TechBash is Nov 12-15 2019 at the Kalahari Resort in Pocono Manor, PA.

Please see www.techbash.com for more details.

Sessions/Content

20181003_090623Of course, the main reason to attend any technical conference has to be the content! We’ve got plenty of it. What do you want to learn? We’ve got languages (C#, Go, JavaScript, etc.), Client Side stuff (Angular, React, Vue, Web Components, PWAs, CSS, etc.), Azure, DevOps, .NET Core, Azure, Testing, Machine Learning, and AI. We cover ASP.NET, .NET Core, and Entity Framework. Plus, there is more to our careers than just tech, so we help you out with soft skills to including sessions on Imposter Syndrome, Hiring, and Diversity and Inclusion. The list goes on and on. Check out our schedule at https://techbash.com/2019-schedule

Speakers

I can’t say enough good things about the talented professionals that travel to TechBash to share their expertise with you! We bring in a diverse group of speakers from around the world, some representing top companies and products too. Many of these speakers do this simply because it is their passion. We are lucky to be a part of this great community.

Workshops

This year we are lucky to have 4 awesome workshops. I must mention, the workshops cost extra but they are well worth the price. In these workshops, you get a deep dive into a topic and often get hands on experience too. This kind of learning can only be possible with a full-day workshop!

From Zero to Hero with Azure DevOps presented by Paul Hacker – DevOps Architect at Microsoft

Modernizing Your Apps to .NET Core / .NET 5 presented by Sean Killeen – .NET Specialty Lead, Excella

Intro to Web Components presented by John Riviello – Distinguished Engineer at Comcast & Chris Lorenzo – Distinguished Engineer at Comcast

Doing more with Serverless on Azure presented by Rich Ross – MTC Technology Architect (Microsoft) and amateur live-streamer

Water Slides

barrellingbaboon768x432Ok, it is up to you whether or not you tell your boss this part, but TechBash isn’t just about learning new tech. TechBash is FUN! TechBash is hosted at the Kalahari Resort in the Pennsylvania Poconos – a 220,000 square foot indoor water park! Bring a bathing suit.

Code of Conduct & Emphasis on Diversity

You may think it is odd that I list a code of conduct on the list of things that makes TechBash great. But we have established a forum for attendees, speakers, sponsors, and staff to all come together and feel comfortable knowing that they will all be respected. We are pretty proud of that. This year we are even hosting a panel on diversity. We want this kind of environment to spread from our event to your workplace!

Family Day Content

Bring the family along to TechBash! While you are learning, they can explore the waterpark and other great activities at the Kalahari and the surrounding area. And on Friday, we’ll provide lots for the kids to do. Take the kids out of school for the day, they’ll learn a lot with many STEM topics.

Lego Open Build, Gaming, Martial Arts, A Reptile Show, Application Development Workshop, Engineering Challenge, and more!

Attendee Party

20181003_203606Once again, I am talking about fun. But networking is an important part of our careers. Please join us for the evening attendee party, have some fun, meet your peers, and relax! If the weather is good, we’ll open the doors and enjoy the fire pits and fresh air on the patio.

Game Night

20181004_194200OK, when my colleagues suggested that we have game night at TechBash, I was a bit unsure about the idea. But I was really wrong about this. Game night is really fun. Attendees are all welcome down at the lounge for board games, card games, ping pong, giant Jenga and much more. We’ll have some snacks and a cash bar. If the weather is nice, we’ll have fire pits and corn hole outside.

Food

20181004_144058It’s a conference but we’ve got to eat too! Our attendees have consistently commented that TechBash has the best food and snacks of any conference. We can’t take much credit for that but we are lucky the Kalahari chef’s do such a great job.

Location

The organizers of TechBash started this conference because we were tired of traveling across the country for Tech events. So we put this conference together close to where millions of people live and work – the northeast. TechBash is less than 2 hours from NYC and Philly. That makes it a pretty easy drive from Albany, Baltimore and Harrisburg and many more areas too.

Water Slides

Yeah, I know I said this already. But seriously, the indoor water park is 220,000 square feet! It is insane and loads of fun.

Keynote

We’ve had great keynote speakers in the past and 2019 is no exception. This year, we’ve got Jeffrey T, Fritz, Senior Program Manager in Microsoft’s Developer Division. You may also know him from his very popular live stream show on Twitch: Fritz and Friends. Jeff has a huge following on line and he has earned it by delivering top notch content.

Attendee Lounge and “The Hallway” Track

20181003_203606Many people say you learn the most at a tech conference in the hallway. In the hallway, you can meet up with presenters, ask follow up questions and keep learning. We’ve taken that to the next level by providing an awesome space for networking, collaboration, and relaxation – the Attendee Lounge. Relax on the couch or get some fresh air on the patio. Meet up with old friends and new.

Live Stream and Recorded Content

We’ll even be live streaming some of the content from TechBash! So if you can’t make it, I hope you will catch a session on line. And if you attend one of the recorded sessions, it’s great to be able to re-play it later at home for review. Of course, it’s best to be here in person where you can ask questions and interact Smile.

Tesla Chargers

OK, this may not be that important to you but I recently bought a Tesla. I just found out the Kalahari has Tesla chargers on site! I’m told that the chargers are part of the valet parking service which is $30 per night. I’ve also read online where the Kalahari may waive the fee for some “charging only” situations but I make no guarantees. Either way, I’ll be getting a charge.

Philly.Net recently had a very successful event called CSharpenUp. We spent the day talking about some advanced topics for C# developers. We had 4 speakers and 80+ attendees. The feedback was very positive, everyone learned a lot and had fun too. If we can set it up, we’ll do the same event in the fall for those that missed it.

I’m still gathering code samples from the other presenters. But for now, here is mine:

Code samples and slides for my LINQ session: Intro to LINQ

Code samples and slides for my Unit Testing session: Unit Testing Made Easy

Also, FYI we did try to record the sessions using Camtasia. Unfortunately, the mic we used wasn’t that great. I’m trying to salvage mine but I may just re-record them.

When I write code, one of my big concerns is how will I test it. I’ve learned that when I see a static method, it is going to make things more complicated than I would like. However, resolving that isn’t usually too difficult. Converting a string value into an Enum is a perfect example. Of course, parsing the string may succeed or fail and I need to know how my code will behave in either case, hence the reason for the unit tests.

In order to make unit testing a bit easier, I wrote a simple class to help out. Basically, this class “wraps” Enum.TryParse() and of course, implements and interface. I’m also using some simple generics to make the casting a little prettier. Since I used an interface, I can now using MOQ, RhinoMocks, or any other framework to mock my dependency and control how it behaves.

You may note that I didn’t call the methods Parse. Instead, I used the name Adapt. That is just a naming convention of my current project so it made sense to be consistent. Feel free to rename this as you wish :)

Here is the interface:

public interface IStringToEnumAdapter
{
     T Adapt<T>(string value) where T: struct;
     bool TryAdapt<T>(string value, out T? result) where T : struct;
}

You’ll probably notice that my generic constraint is struct. That is because you can’t use Enum as a generic constraint. So struct is the best I’ve got to work with. And considering we are doing parsing here, if you pass any other stuct in, it is going to fail on the parse anyway. So I think it is pretty safe.

Here is the implementation:

public class StringToEnumAdapter : IStringToEnumAdapter
{
    public T Adapt<T>(string value) where T : struct
    {
        T result;
        
        bool success = Enum.TryParse(value, true, out result);
 
        if (success)
            return result;
 
        throw new InvalidEnumArgumentException(string.Format("{0} could not be converted to {1}", value, typeof(T).Name));
    }
 
    public bool TryAdapt<T>(string value, out T? result) where T : struct
    {
        T parsedValue;
        bool success = Enum.TryParse(value, true, out parsedValue);
 
        result = success ? parsedValue : (T?)null;
 
        return success;
    }
}

Guess what? It isn’t all that complicated right? If you are getting into testing, you’ll soon find out that simple steps like this make life a lot easier.

Click here to download the class and unit tests for it too.

Last night I had the pleasure of presenting “Unit Testing Made Easy” at NoDeNUG (Northern Delaware .Net User Group).  I’ll be doing the same demo at Philly.Net Code Camp next week.  The NoDeNUG crowd was great and asked good questions.  That made the demo fun for me and I think it went very well.  I hope it goes over great at Code Camp too. 

I’m attaching a zip file containing my slides and Visual Studio Solution.  The demo should work fine on it’s own, the references to NUnit, MOQ, and StructureMap are all included.  But if you don’t have VS2010 with Premium or Ultimate and Feature Pack 2, the CodedUI (testing for Silverlight UIs) won’t work.  I hope it will build and run ok though.  If not, let me know and I’ll upload the solution without references to the Coded UI stuff.  Also, the demo uses a Silverlight application for the front end.  If you don’t have the Silverlight tools set up, you can either add them to Visual Studio, or simply exclude the Silverlight projects.  You’ll still be able to run the services and the unit tests, even if you can’t see how the UI looks.

If you’ve just come across this and haven’t heard my presentation you have two options:

1. Come to Philly.Net Code Camp next week (April 9) and hear the presentation then!

2. Just open the enclosed solution and have a look!  I’ve got sample code in there to demonstrate using Dependency Injection to make services easier to unit test, sample unit tests, and sample tests using mocking of dependencies.  I’m coding my tests with NUnit, using StructureMap for my IOC, and MOQ as my mocking framework.

Here is the code:  UnitTestingMadeEasy.zip

Again, if you have any problems with the solution, let me know and I’ll upload a copy without the Coded UI, or even without the Silverlight part.