From b8fae4fa428b00c0b57fa7c16378aa34c2b4691e Mon Sep 17 00:00:00 2001 From: Dan <daniel2.lorych@live.uwe.ac.uk> Date: Wed, 4 May 2022 20:42:44 +0100 Subject: [PATCH] Add Configurator unit tests --- UnitTests/ConfiguratorTests.cs | 58 +++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/UnitTests/ConfiguratorTests.cs b/UnitTests/ConfiguratorTests.cs index 2245f21..4c0ae72 100644 --- a/UnitTests/ConfiguratorTests.cs +++ b/UnitTests/ConfiguratorTests.cs @@ -1,20 +1,70 @@ using System; +using Helios.Models; +using Helios.Source; using NUnit.Framework; namespace UnitTests { public class ConfiguratorTests { - [SetUp] - public void Setup() + [Test] + public void GetElevationAngle_SunAngle_ReturnsAngle() + { + Roof roof = new Roof(); + roof.Elevation = 25; + + int elevationAngle = roof.GetElevationAngle(60); + + Assert.AreEqual(85, elevationAngle); + } + + [Test] + public void GetPowerOutput_MockNumbers_ReturnsExpected() + { + SolarPanel panel = new SolarPanel(); + panel.Efficiency = 0.2; + + int solarEnergy = 1000; + int roofArea = 7; + int roofElevation = 85; + + double powerOutput = panel.GetPowerOutput(solarEnergy, roofArea, roofElevation); + + Assert.AreEqual(1394.67, Math.Round(powerOutput, 2)); + } + + [Test] + public void GetInstallationCost_MockArea_ReturnExpected() { + SolarPanel panel = new SolarPanel(); + panel.CostPerMetreSquared = 100; + + int roofArea = 7; + + double installationCost = panel.GetInstallationCost(roofArea); + + Assert.AreEqual(700, installationCost); } [Test] - public void Test1() + public void GetCostPerWatt_MockPanel_ReturnExpected() { - Assert.Pass(); + SolarPanel panel = new SolarPanel(); + panel.Efficiency = 0.2; + panel.CostPerMetreSquared = 100; + + int solarEnergy = 1000; + int roofArea = 7; + int roofElevation = 85; + + panel.GetInstallationCost(7); + panel.GetPowerOutput(solarEnergy, roofArea, roofElevation); + + double costPerWatt = panel.GetCostPerWatt(); + + Assert.AreEqual(0.50, Math.Round(costPerWatt, 2)); } + } } -- GitLab