Skip to content

CodecoolGlobal/histogram-csharp-Daniel-Salyik

Repository files navigation

Histogram – Unit Testing Practice Project (C#)

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.

Project Goal

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

Application Overview

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.

Domain Classes

  • 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.

Testing Focus

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.

Running the Project

Prerequisites

  • .NET SDK

Clone and Run

Run Unit Tests

  • dotnet test tests/Codecool.Histogram.UnitTests/Codecool.Histogram.UnitTests.csproj

Run the Application

  • dotnet run --project src/Codecool.Histogram/Codecool.Histogram.csproj

Technologies Used

  • C#
  • .NET
  • NUnit
  • JetBrains Rider

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages