C# – How to split a string

String can be split into collection of substrings based on a defined character (separator) using Split() function. Split is part of String class which exists in the System namespace.

Split function is overloaded and has various forms which allow to:

  • pass separator as a single character, array of characters, single string or array of strings;
  • define maximum number of substrings in output array;
  • define split options like removing empty elements from returned collection.
Continue reading C# – How to split a string

Mutation Testing with C# and .NET Core

Unit Testing is widely known method of validating results produced by a code in an automated manner. Good test coverage helps with maintaining a code as it is much easier and quicker to spot potential bugs after code changes. How to check if a test suite is effective though? One of the answers is to use Mutation Testing.

The idea is to create mutants which are modified versions of your code and run existing unit tests against these mutants. If a mutation caused test run failure it means a mutant is killed (which is good). If the tests passed then a mutant survived (which is not good). The measurement of the unit tests quality is percentage of the killed mutants where the higher figure is the better. In this approach we expect the test run to fail on mutated code otherwise either not all paths are covered by the unit tests or your tests miss some conditions.

Continue reading Mutation Testing with C# and .NET Core