Skip to content

shahmirn/OhmValueCalculatorDotNetCore

Repository files navigation

Ohm Value Calculator - .NET Core Backend - Showcase Project

Project Requirements

public interface IOhmValueCalculator
{
   /// <summary>
   /// Calculates the Ohm value of a resistor based on the band colors.
   /// </summary>
   /// <param name="bandAColor">The color of the first figure of component value band.</param>
   /// <param name="bandBColor">The color of the second significant figure band.</param>
   /// <param name="bandCColor">The color of the decimal multiplier band.</param>
   /// <param name="bandDColor">The color of the tolerance value band.</param>
   int CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor);
}
  • Write the unit tests you feel are necessary to adequately test the code.

Working Demo

Version

0.0.1

Tech

  • Visual Studio 2017 - Fully-featured integrated development environment (IDE) for Android, iOS, Windows, web, and cloud.
  • .NET Core - A developer platform for building all your apps.
  • NUnit - NUnit is a unit-testing framework for all .Net languages.
  • Fluent Assertions - A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests.

Running Locally

Running tests

  • If using Visual Studio
    • Go to Build, then Build Solution
    • Go to Test, Windows, then Test Explorer
    • Click on Run All
  • If using command line / .NET Core 2.2 SDK
    • cd OhmValueCalculatorDotNetCore
    • dotnet restore
    • dotnet test OhmValueCalculator.Tests -v n

Continuous Integration (CI)

Interface Deviations

The original problem specified an interface that returns an int.

However, given that band D is the tolerance band, the user would be interested in the resistance of the resistor based on the first three bands, plus the deviation / variance based on the fourth band.

This necessitates returning an object instead, which contains a Resistance, Minimum, and Maximum value.

Corresponding front-end repository

Todo's

  • Add additional code comments
  • Create an enum for the colors for the different bands instead of allowing any arbitrary string
  • Use Swashbuckle.AspNetCore to add swagger documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages