Unit test framework tutorials - Rhino Mocks, MOQ etc.

NUnit Assert Examples - How to Use?

NUnit Assert class is used to determine whether a particular test method gives expected result or not.  In a test method, we write code the check the business object behavior. That business object returns a result. In Assert method we match the actual result with our expected result. If result comes according to our expect result then our test case is passed e...

Continue Reading

NUnit TestCase - Array and Execution Order - NUnit Tutorial

In this C# NUnit tutorial, we'll learn about how to pass same type of objects array into test method and how to control the execution order of test methods. NUnit TestCase Array Below is the example of passing array to a test method. [TestCase(new int[] { 2, 4, 6 })] public void When_AllNumberAreEven_Expects_AreAllNumbersEvenAsTrue(int[] numbers) { N...

Continue Reading

NUnit TestCase C# Tutorial

In our last tutorial, we learned about NUNit TestFixture attribute. In this tutorial, we learn about NUnit TestCase attribute and its usage. TestCase attribute is used for two purposes. It marks a method to Test Method. Pass arguments / parameters to Test Method. Test Method When we assign TestCase attribute to any method that lets NUnit test runner ...

Continue Reading

NUnit TestFixture C# Tutorial

NUnit TestFixture attribute is a class level attribute and it indicates that this class contains NUnit Test Methods. Below are the topics we covered in this tutorial: TestFixture Example and Usage Parameterized TestFixtures TestFixture Inheritance Generic TestFixture TestFixture Restrictions NUnit TestFixture Example and Usage Below is the...

Continue Reading

NUnit Example Test Case - NUnit Tutorial

In our previous post, we learn how to set up environment for our NUnit Project. In this post, we'll learn how to write our first NUnit Test Case with Example in .NET / C#. We have two projects CustomerOrderService project which is a class library and CustomerOrderService.Tests project which is a NUnit test project. First create two classes Customer and Order and ...

Continue Reading

Environment Setup - NUnit Tutorial

There are two steps in configure NUnit project environment: Configure Project with NUnit assemblies Setup TestRunners which show the results of NUnit test cases Configure Project with NUnit assemblies We always creates separate project when creating project for NUnit. According to naming conventions test project name should be [Project Under Test].[Tests]. For e...

Continue Reading

Introduction - NUnit Tutorial

NUnit is most popular tool for doing Unit Testing. Before start, we need to learn what is Unit Testing and why NUnit is a popular tool for doing unit testing. Unit Testing Every software is composed of various modules. Each module is composed of various classes. Classes composed of various functions. Function is the smallest unit of code in the application. When w...

Continue Reading

Environment Setup - Rhino Mocks Tutorial

Rhino Mocks is very easy to setup. There is only one single DLL "Rhino.Mocks.DLL" needs to be included. There are two options to include Rhino Mocks in your solution. Direct download from hibernatingrhinos site. Use NuGet to download DLL. Setup solution using Direct download We can directly download "Rhino.Mocks.DLL" from&nbs...

Continue Reading

Rhino Mocks Tutorial

Rhino Mocks is the mature dynamic mocking framework for .NET unit testing. It create fake/mock implementation of objects behavior at runtime. Rhino Mocks is open source framework and released under the BSD license. Rhino Mocks works on Arrange, Act and Assert (AAA) pattern. Rhino Mocks allows both State verification and Behavior verification of objects...

Continue Reading

Join our newsletter and get an occasional email with a technology and DotNetPattern.com news update.