
Discover the test pyramid: favor unit tests for fast, precise feedback, back them with integration tests for external dependencies, and use end-to-end tests sparingly for key functions.
Write your first unit test for the test ninja reservation class, verifying admin, the owner, or another user can cancel via the CanBeCancelled By method, using arrange-act-assert.
Refactor with confidence using unit tests for C# developers. Tests document code and verify cancellation scenarios (admin, same user, another user) while returning the result of the expression.
In black-box testing for the max method, identify three execution paths: a greater, b greater, and equal, and write tests based on input scenarios rather than implementation.
Learn to temporarily disable a test with NUnit's Ignore attribute, preserving a reason message, so you can focus on other work without deleting or commenting out tests.
Avoid extremes on testing; maintain an essential automated test suite to catch bugs early, because the cost of late fixes outweighs upfront testing, with the double-entry bookkeeping analogy.
Explore the fundamentals of unit testing, building small, isolated tests with a single responsibility that verify outcomes, not implementation, and use setup and parameterized tests for reliability.
Explore how code coverage reveals untested lines, compare DotCover with Visual Studio Enterprise Edition and ReSharper Ultimate, and learn to test all execution paths using black-box thinking.
Learn to implement and refactor unit tests for a DemeritPointsCalculator, using parameterized test cases, exception handling for out-of-range speeds, and a MaxSpeed constant.
Refactor legacy code into a testable, loosely coupled design by extracting resource logic into a class and using an interface as a contract; inject dependencies from outside, enabling test doubles.
Learn to refactor legacy code into a loosely coupled, testable design by extracting file access into a FileReader, creating an IFileReader interface, and using a fake implementation for unit tests.
Create mock objects with the Moq library to test external dependencies, configure IFileReader behavior, and inject mock.Object into your video service.
Use mocks sparingly to remove external resources from tests. Avoid sprawling interfaces and bloated constructors, and keep tests fast and reliable by focusing on external behavior rather than implementation.
Refactor by extracting database access into a video repository to isolate external resources, then inject an IVideoRepository interface into VideoService for testable, loosely coupled unit testing.
Learn to unit test the GetUnprocessedVideos method with mocks, cover empty and multiple videos, and consider repository dependencies and constructor design to keep tests focused.
Practice unit testing the InstallerHelper class by examining its DownloadInstaller method, which uses WebClient to download a file from a constructed URL and returns true or false.
Develop unit tests for the OverlappingBookingsExist booking overlap check in BookingHelper, refactoring for loose coupling and testability while validating cancellations, querying non-cancelled bookings, and returning the first overlap reference.
Develop comprehensive unit tests for overlapping bookings in C# by defining all test cases—before, in middle, after overlaps, and cancellation scenarios—and organize tests in a BookingHelperTests class with mocking.
Unit testing for C# developers guides fixing a bug in booking overlap logic by using a proven two-date overlap condition and expanding tests to validate all scenarios.
Explore unit testing for C# by writing tests for SendStatementEmails, isolate external resources, and apply dependency injection to inject SaveStatement and EmailFile dependencies.
Learn to write the first interaction test for a C# application service by mocking the unit of work and collaborators, and verifying statement generation and email sending for housekeepers.
Keep tests clean by introducing a setUp method, promoting shared objects to private fields, and reducing duplication so each test starts with fresh unit of work and mocks.
Master c# unit testing with mocks and setup to verify email sending of the statement when a valid file name is returned, and prevent sending for null or empty names.
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:
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:
You’ll get: