Skip to content
UdemySoftware TestingPaid courseAll LevelsCertificate

Unit Testing for C# Developers (Udemy.com)

Master unit testing C# code with NUnit and Moq: all about dependency injection, best practices and pitfalls to avoid

Created by: Mosh Hamedani

Last updated April 2018

icon
What you will learn

  • Learn unit testing from scratch
  • Tips and tricks to write clean, maintainable and trustworthy tests
  • Write loosely-coupled and testable code
  • Refactor legacy code towards testable code
  • Understand and implement dependency injection
  • Use mocks to isolate code from external dependencies
  • Apply the unit testing best practices
  • Learn the anti-patterns to avoid

How it compares

Against the other 281 rated Udemy courses in Software Testing on CourseDuck:

  • Rating4.6 out of 5higher than 71% of them
  • Reviews13,887#14 of 282 by number of reviews
  • Length5.8 hoursshorter than 57% of them
  • Last updatedApril 2018earlier than 94% of them

icon
Quality Score

Content Quality
/
Video Quality
/
Qualified Instructor
/
Course Pace
/
Course Depth & Coverage
/

Overall Score : 92 / 100

icon
Course Description

Picture this: you make a simple change to the code and suddenly realize that you created a dozen unexpected bugs. Sound familiar? You’re not alone!

Good news is, unit testing can make this a thing of the past.

Maybe you’ve heard of automated or unit testing before and you’re keen to learn more.

Or perhaps you’ve tried to learn it and got a bit lost or ended up with fat and fragile tests that got in the way and slowed you down.

Either way, what you need is a course that will teach you all you need to know about this essential skill - from the basics, right through to mastery level.


What is unit testing?

In a nutshell: it’s the practice of writing code to test your code and then run those tests in an automated fashion.


Why learn unit testing?

Why write extra code? Wouldn’t that take extra time to write? Would that slow you down? Why not just run the application and test it like an end user?

Thinking like this is the mistake lots of people make. I used to make it myself. I’ve had to learn the hard way!

I learned pretty fast that if you’re building a complex application or working on a legacy app, manually testing all the various functions is tedious and takes a significant amount of time.


As your application grows, the cost of manual testing grows exponentially. And you’re never 100% sure if you’ve fully tested all the edge cases. You’re never confident that your code really works until you release your software and get a call from your boss or an end user!

Several studies have shown that the later a bug is caught in the software development lifecycle, the more costly it is to the business.

Automated tests help you to catch bugs earlier in the software development lifecycle, right when you’re coding. These tests are repeatable. Write them once and run them over and over.


The benefits of using unit tests are:

  • help you to catch and fix bugs earlier, before releasing your app into production
  • help you to write better code with less bugs
  • help you to produce software with better design - extensible and loosely-coupled
  • give you rapid feedback and tell you if your code *really* works
  • force you to think of edge cases that you didn’t realize existed
  • test your code much faster
  • tell if you have broken any functionality as you write new code
  • allow you to refactor your code with confidence
  • act as documentation about what your code does
  • save you both time and money


A valuable skill for senior developers

More and more companies are recognizing the advantages of automated testing, that’s why it’s a must-have for senior coders. If you’re looking to reach the higher levels in your coding career, this course can help.

You don’t need any prior knowledge of automated testing. You only need 3 months of experience programming in C#.


With this course you’ll learn:

  • senior coder secrets - best practices to write great unit tests
  • tips and tricks to keep your tests clean, trustworthy and maintainable
  • the pitfalls to avoid – anti-patterns
  • how to refactor legacy, untestable code into loosely-coupled and testable code
  • all about dependency injection – the one thing every coder needs to know
  • the power of mocks – when and how to use them and when to avoid


You’ll get:

  • 6 hours of HD video
  • tutorials and guidance from a senior coder with 15+ years’ experience
  • exercises with step-by-step solution
  • downloadable source code
  • lifetime access
  • access online or offline at any time on any device
  • certificate of completion to present to your current or prospective employer

icon
Udemy Discount

The discount is applied through our link. Open the course from here and Udemy's current promotional price is applied at checkout on most courses, no code to type.

Some courses are excluded from Udemy's promotions. If the price does not drop, clear your browser cookies and use the button again.

icon
Instructor Details

Mosh Hamedani

Hi! I'm Mosh, a software engineer with over 20 years of experience. I'm all about clear, concise, practical coding tutorials – no fluff, just the good stuff! My courses focus on real-world projects and the skills that will get you hired. I've helped millions of students transform their careers. Want to level up your skills? Check out my courses and get started.

icon
More courses by Mosh Hamedani

$149.99

$17.99

$109.99

$19.99

$124.99

$94.99

icon
More Software Testing courses

$59.99

$84.99

$10.99

$10.99

$13.99

$149.99

icon
Reviews

4.6

13,887 ratings on Udemy

Select a bar to show only those reviews.Select the bar again to show every rating.

By Fabio Guedes on 6/23/2023

Your course has pushed me in the way of how to understand unit testing because as I am from the old school of programming that what you explain did not exist (I used a lot in my head to work, in terms of programming logic, according to the validation of values as if testing in the application in a testing environment). I really lingered on the term "understanding" with each implementation you did, and ended up waking up in reality how unit testing works in Visual Studio. I pass on my congratulations for your efforts! :-)

By Yavor Ivanov on 11/9/2021

Courses like this are one of the reasons I like Mosh so much. It is a really great course to get the main idea and principles. Exercises are the jewel in the crown. Especially for developers who have experience, but didn’t have the chance to work on projects with unit tests. Believe it or not, there are too many product/service companies that think that unit tests are too expensive for them, and they prefer not to pay for this. This is somehow normal for the service companies, but not so normal for the product ones.

By Babak Behravesh on 12/27/2020

All content presented in a very good way, really way beyond what I expected from an online course. The exercises are amazing as they show that Mosh has picked them up thoughtfully, brought them into the course and shared their solution with great details. He covered mocking, refactoring with focus on Unit testing and dependency injection very well. There is a small missing piece on not using any of the DI tools addressed in the tutorial. He mentioned that using a DI tool from a MVC application and WebAPI can be different, even the coding syntax for each DI tool is different from another. That's fine but even a small example on using say, Autofac on a Console application could give a very good idea on how to use the tool. This should be taking 5-10 mins of video. BTW, If someone asks me, does it worth I spend my 9 days of Christmass holidays (in this Corona crisis) to take up this course, I would say Yes, go for it! I personally did it and I'm happy with what I have done!

By Farah karim on 12/16/2019

Oui il correspondait parfaitement à mes attentes. Le cours est bien présenté, avec beaucoup de pédagogie. Pas de pertes de temps dans les explications, les informations données on été bien mesurées. Les exemples sont clairs et se comprennent bien. L'instructeur n'hésite pas à donner son avis sur les bonnes ou mauvaises pratiques selon son expérience. Beaucoup de pratique à travers les exercices données. Excellent, recommandé vivement pour ceux qui débutent sur ce type de problématique.

By Thomas Lorenz on 3/11/2019

Ich fange mit dem Thema Unittests gerade an und dieser Kurs hat mir sehr viel Wissen vermittelt. Der Kurs ist sehr gut gegliedert, geht in sehr übersichtlichen Schritten durch das Thema. Der Sprecher erläutert das Wissen sehr kompetent und mit angenehmer Stimme. OK, ich kaufte den Kurs für 12 Euro, aber auch den normalen Preis halte ich für in Ordnung. Einen Wunsch habe ich noch: Das die Einbindung von DataDrivenTests erfolgt. Trotzdem : volle fünf Sterne.

By Sebastian Kuliński on 2/6/2019

I've found this course excellent to build up foundations not only for Unit testing but also great explanations of more advanced topic in C#. It's not course for beginners for sure, requires to have already experience - I was able to understand and follow with my humble knowledge but couldn't came up with my own solutions for those problems. I'm sure that I'll come back to this course more than once to get back on right track after getting more and more experience.

By Maxime Gaudreau on 7/6/2018

This is not my first course with and, as usual, he delivered some pretty solid and professional material. I'm very satisfied with the course. However, I got it on discount and I would probably have been a little disappointed had I paid the original full price. I feel that it could have gone deeper and touched integration testing a bit deeper with a couple examples. Overall: Great job. When I take a new course, my goal is always to be a better and more experienced developer when it's done. That's how I feel after this one.

By Milos Bencek on 6/14/2018

Instructor was very knowledgeable however his demonstration were more focused on real life scenarios rather than on education. F.e.: he was constantly using implicit type 'var' instead of full specified type reference which I didn't find suitable for tutorials and it slowed down my progress by constantly searching for answers in alternative sources. Other thing I didn't like was excessive using of Re-Sharper which was distracting. Despite of those two facts I would buy Mosh's tutorial again but I would have to combine it with other sources and tutorials to fully understand demonstrations and learning topics.

By Eduardo Chávez on 4/25/2018

Un curso muy completo y practico te explica desde cero es claro y conciso , lo recomiendo ampliamente y todo se puede aplicar en situaciones reales, compraria otro curso si el lo imparte. Damn awesome course! from scratch, applicable to the real world, Mosh explain simple and provide exercises and its solutions I really like the course and I will buy another related to what I want if Mosh is the instructor. Highly recommended

By Chris Shaw on 4/12/2018

Another brilliant course by Mosh. I've watched his MVC, C# beginner/intermediate/advanced, entity framework and now the unit test courses. All thorough with examples and explanations for real world scenarios. This course really extends your knowledge on interfaces and dependency injection, making them simple to understand so you can test methods easily. Definitely recommended!

Showing all 10 reviews on CourseDuck

Read all 13,887 reviews on Udemy