This is a simple console application that analyzes a text and generates a histogram based on word length ranges.
The goal of this project was to implement the NormalizeValues method and to add thorough unit tests to an existing codebase, practicing writing meaningful tests and covering edge cases.
The original implementation contained:
- working domain logic
- no automated tests
My task was to:
- understand the existing behavior
- design meaningful unit tests
- cover edge cases and boundary conditions
- improve confidence in the code without changing production classes
The application:
- reads a text from a file
- groups words by their length using predefined ranges
- generates a histogram showing word distribution
- optionally normalizes histogram values using Min–Max normalization
- prints the result to the console
This project is a simple console application, used as a testing target.
-
TextReader
- Reads text content from a file
-
Range
- Represents a word length interval
-
Histogram
- Generates word-length distributions
- Produces a textual histogram representation
The domain logic was used as-is. Unit tests were written to verify its behavior, including handling of edge cases and repeated calls.
Unit tests were added using NUnit, with emphasis on:
- constructor validation and invalid inputs
- boundary conditions (empty text, null values, out-of-range words)
- repeated method calls and state reset behavior
- platform-independent string formatting (
Environment.NewLine)
The tests focus on behavior, not implementation details.
- .NET SDK
- git clone https://github.com/CodecoolGlobal/histogram-csharp-Daniel-Salyik.git
- cd histogram-csharp-Daniel-Salyik
- dotnet test tests/Codecool.Histogram.UnitTests/Codecool.Histogram.UnitTests.csproj
- dotnet run --project src/Codecool.Histogram/Codecool.Histogram.csproj
- C#
- .NET
- NUnit
- JetBrains Rider