Tags

C# reflection, interfaces, abstract class, generics, ref vs out, C# versions 4,5,6 and features.

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) { Number number = new Number...

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 one enum CustomerType in Cus...

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 example, if we are t...

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 we test individual functi...

Continue Reading

LINQ SelectMany Operator

SelectMany operator is used when we have a sequence of objects which has a collection property and we need to enumerate each item of child collection one by one. SelectMany operator comes under Projection operators category of LINQ Query Operators. Below is the syntax of SelectMany operator public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<...

Continue Reading

LINQ Contains Operators

LINQ Contains operator is used to check whether an element is available in sequence (collection) or not. Contains operator comes under Quantifier Operators category in LINQ Query Operators. Below is the syntax of Contains operator. public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value); public static bool Contains<TSource>(this IEnumerable...

Continue Reading

LINQ Any Operator

LINQ Any operator comes under Quantifier Operators category in LINQ Query operators. LINQ Any operator is used for two cases: Check whether sequence is blank or not. Check whether any single element in a sequence satisfy a given condition or not. Any operator is only available in Method syntax and not available in Query Syntax. Below is the syntax of Any operator public stati...

Continue Reading

LINQ All Operator

LINQ All operator is used to check whether all elements in a sequence (collection) satisfy a particular condition or not. LINQ All operator comes under Quantifier Operators category in LINQ Query Operators. Lets take an example, we have a collection A = { 3, 6, 9, 12 } and we have to check whether all elements in this sequence is divide by 3 or not. For this we use All operator and pass predic...

Continue Reading

LINQ Distinct Operator

LINQ Distinct operator is used for removing duplicates elements from the sequence (list). Distinct operator comes under Set operators category in LINQ query operators. For example, we have one collection A = { 1, 2, 3, 3, 4, 4, 5}. In this collection 3 and 4 elements are repeated two times and we have to create a new sequence which takes these duplicates only one time. So we use distinct opera...

Continue Reading

LINQ Intersect Operator

LINQ Intersect operator is used to find common elements between two sequences (collections). Intersect opertor comes under Set operators category in LINQ Query operators. For example, we have two collections A = { 1, 2, 3 } and B = { 3, 4, 5 }. Intersect operator will find common elements in both sequences. { 3 } element is common in both sequences. So Intersect operator only shows one element...

Continue Reading