Skip to content

Commit

Permalink
Project foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisJensen95 committed Aug 27, 2023
1 parent bfaee80 commit a47bf22
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
backend-ci:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Nix
uses: cachix/install-nix-action@v20

- name: Load Nix shell
working-directory: ./apps/EnergyAnalyzer
run: nix-shell ../../shell.nix --run "just test"
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Nix environment
.config

# C#
bin/
obj/

# Test results
TestResults/
coveragereport
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "apps/EnergyAnalyzer/EnergyAnalyzer.sln"
}
12 changes: 12 additions & 0 deletions apps/EnergyAnalyzer/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.1.24",
"commands": [
"reportgenerator"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="../EnergyAnalyzerWebApp/EnergyAnalyzer.csproj" />
</ItemGroup>

</Project>
40 changes: 40 additions & 0 deletions apps/EnergyAnalyzer/EnergyAnalyzer.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Linq;
using EnergyAnalyzer.Controllers;
using Microsoft.Extensions.Logging;
using Moq;
using Xunit;

namespace EnergyAnalyzer.Tests
{
public class WeatherForecastControllerTests
{
private readonly WeatherForecastController _controller;
private readonly Mock<ILogger<WeatherForecastController>> _loggerMock;

public WeatherForecastControllerTests()
{
_loggerMock = new Mock<ILogger<WeatherForecastController>>();
_controller = new WeatherForecastController(_loggerMock.Object);
}

[Fact]
public void Get_ReturnsWeatherForecasts()
{
// Arrange
// Setup is done in the constructor

// Act
var result = _controller.Get();

// Assert
Assert.NotNull(result);
Assert.Equal(5, result.Count());
foreach (var forecast in result)
{
Assert.NotNull(forecast);
Assert.True(forecast.TemperatureC >= -20 && forecast.TemperatureC <= 55);
Assert.True(WeatherForecastController.Summaries.Contains(forecast.Summary));
}
}
}
}
1 change: 1 addition & 0 deletions apps/EnergyAnalyzer/EnergyAnalyzer.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
154 changes: 154 additions & 0 deletions apps/EnergyAnalyzer/EnergyAnalyzer.Tests/coverage.opencover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<CoverageSession>
<Summary numSequencePoints="35" visitedSequencePoints="20" numBranchPoints="2" visitedBranchPoints="0" sequenceCoverage="57.14" branchCoverage="0" maxCyclomaticComplexity="9" minCyclomaticComplexity="9" visitedClasses="2" numClasses="3" visitedMethods="6" numMethods="8" />
<Modules>
<Module hash="2E4C5E1B-744F-48C0-879C-5B4B6819D432">
<ModulePath>EnergyAnalyzer.dll</ModulePath>
<ModuleTime>2023-08-27T07:35:56</ModuleTime>
<ModuleName>EnergyAnalyzer</ModuleName>
<Files>
<File uid="1" fullPath="/Users/dennisjensen/GIT/energy-grid/apps/EnergyAnalyzer/EnergyAnalyzerWebApp/Program.cs" />
<File uid="2" fullPath="/Users/dennisjensen/GIT/energy-grid/apps/EnergyAnalyzer/EnergyAnalyzerWebApp/WeatherForecast.cs" />
<File uid="3" fullPath="/Users/dennisjensen/GIT/energy-grid/apps/EnergyAnalyzer/EnergyAnalyzerWebApp/Controllers/WeatherForecastController.cs" />
</Files>
<Classes>
<Class>
<Summary numSequencePoints="14" visitedSequencePoints="0" numBranchPoints="2" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="0" maxCyclomaticComplexity="2" minCyclomaticComplexity="2" visitedClasses="0" numClasses="1" visitedMethods="0" numMethods="1" />
<FullName>Program</FullName>
<Methods>
<Method cyclomaticComplexity="2" nPathComplexity="2" sequenceCoverage="0" branchCoverage="0" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="14" visitedSequencePoints="0" numBranchPoints="2" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="0" maxCyclomaticComplexity="2" minCyclomaticComplexity="2" visitedClasses="0" numClasses="0" visitedMethods="0" numMethods="1" />
<MetadataToken />
<Name>System.Void Program::&lt;Main&gt;$(System.String[])</Name>
<FileRef uid="1" />
<SequencePoints>
<SequencePoint vc="0" uspid="1" ordinal="0" sl="1" sc="1" el="1" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="3" ordinal="1" sl="3" sc="1" el="3" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="5" ordinal="2" sl="5" sc="1" el="5" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="6" ordinal="3" sl="6" sc="1" el="6" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="8" ordinal="4" sl="8" sc="1" el="8" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="11" ordinal="5" sl="11" sc="1" el="11" ec="2" bec="2" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="12" ordinal="6" sl="12" sc="1" el="12" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="13" ordinal="7" sl="13" sc="1" el="13" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="14" ordinal="8" sl="14" sc="1" el="14" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="15" ordinal="9" sl="15" sc="1" el="15" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="17" ordinal="10" sl="17" sc="1" el="17" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="19" ordinal="11" sl="19" sc="1" el="19" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="21" ordinal="12" sl="21" sc="1" el="21" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="23" ordinal="13" sl="23" sc="1" el="23" ec="2" bec="0" bev="0" fileid="1" />
</SequencePoints>
<BranchPoints>
<BranchPoint vc="0" uspid="11" ordinal="0" path="0" offset="64" offsetend="66" sl="11" fileid="1" />
<BranchPoint vc="0" uspid="11" ordinal="1" path="1" offset="64" offsetend="84" sl="11" fileid="1" />
</BranchPoints>
<MethodPoint vc="0" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="1" ec="1" el="23" bec="0" bev="0" fileid="1" xmlns:p8="xsi" />
</Method>
</Methods>
</Class>
<Class>
<Summary numSequencePoints="4" visitedSequencePoints="3" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="75" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="1" numClasses="1" visitedMethods="3" numMethods="4" />
<FullName>EnergyAnalyzer.WeatherForecast</FullName>
<Methods>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="True" isSetter="False" isStatic="True">
<Summary numSequencePoints="1" visitedSequencePoints="1" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.DateTime EnergyAnalyzer.WeatherForecast::get_Date()</Name>
<FileRef uid="2" />
<SequencePoints>
<SequencePoint vc="5" uspid="5" ordinal="0" sl="5" sc="1" el="5" ec="2" bec="0" bev="0" fileid="2" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="1" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="5" ec="1" el="5" bec="0" bev="0" fileid="2" xmlns:p8="xsi" />
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="True" isSetter="False" isStatic="True">
<Summary numSequencePoints="1" visitedSequencePoints="1" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Int32 EnergyAnalyzer.WeatherForecast::get_TemperatureC()</Name>
<FileRef uid="2" />
<SequencePoints>
<SequencePoint vc="15" uspid="7" ordinal="0" sl="7" sc="1" el="7" ec="2" bec="0" bev="0" fileid="2" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="1" uspid="0" p8:type="SequencePoint" ordinal="1" offset="1" sc="0" sl="7" ec="1" el="7" bec="0" bev="0" fileid="2" xmlns:p8="xsi" />
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="0" branchCoverage="100" isConstructor="False" isGetter="True" isSetter="False" isStatic="True">
<Summary numSequencePoints="1" visitedSequencePoints="0" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="0" numMethods="1" />
<MetadataToken />
<Name>System.Int32 EnergyAnalyzer.WeatherForecast::get_TemperatureF()</Name>
<FileRef uid="2" />
<SequencePoints>
<SequencePoint vc="0" uspid="9" ordinal="0" sl="9" sc="1" el="9" ec="2" bec="0" bev="0" fileid="2" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="0" uspid="0" p8:type="SequencePoint" ordinal="2" offset="2" sc="0" sl="9" ec="1" el="9" bec="0" bev="0" fileid="2" xmlns:p8="xsi" />
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="True" isSetter="False" isStatic="True">
<Summary numSequencePoints="1" visitedSequencePoints="1" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.String EnergyAnalyzer.WeatherForecast::get_Summary()</Name>
<FileRef uid="2" />
<SequencePoints>
<SequencePoint vc="10" uspid="11" ordinal="0" sl="11" sc="1" el="11" ec="2" bec="0" bev="0" fileid="2" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="1" uspid="0" p8:type="SequencePoint" ordinal="3" offset="3" sc="0" sl="11" ec="1" el="11" bec="0" bev="0" fileid="2" xmlns:p8="xsi" />
</Method>
</Methods>
</Class>
<Class>
<Summary numSequencePoints="17" visitedSequencePoints="17" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="1" numClasses="1" visitedMethods="3" numMethods="3" />
<FullName>EnergyAnalyzer.Controllers.WeatherForecastController</FullName>
<Methods>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="9" visitedSequencePoints="9" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Collections.Generic.IEnumerable`1&lt;EnergyAnalyzer.WeatherForecast&gt; EnergyAnalyzer.Controllers.WeatherForecastController::Get()</Name>
<FileRef uid="3" />
<SequencePoints>
<SequencePoint vc="1" uspid="23" ordinal="0" sl="23" sc="1" el="23" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="24" ordinal="1" sl="24" sc="1" el="24" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="25" ordinal="2" sl="25" sc="1" el="25" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="26" ordinal="3" sl="26" sc="1" el="26" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="27" ordinal="4" sl="27" sc="1" el="27" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="28" ordinal="5" sl="28" sc="1" el="28" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="6" uspid="29" ordinal="6" sl="29" sc="1" el="29" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="30" ordinal="7" sl="30" sc="1" el="30" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="31" ordinal="8" sl="31" sc="1" el="31" ec="2" bec="0" bev="0" fileid="3" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="9" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="23" ec="1" el="31" bec="0" bev="0" fileid="3" xmlns:p8="xsi" />
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="True" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="4" visitedSequencePoints="4" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Void EnergyAnalyzer.Controllers.WeatherForecastController::.ctor(Microsoft.Extensions.Logging.ILogger`1&lt;EnergyAnalyzer.Controllers.WeatherForecastController&gt;)</Name>
<FileRef uid="3" />
<SequencePoints>
<SequencePoint vc="1" uspid="16" ordinal="0" sl="16" sc="1" el="16" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="17" ordinal="1" sl="17" sc="1" el="17" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="18" ordinal="2" sl="18" sc="1" el="18" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="19" ordinal="3" sl="19" sc="1" el="19" ec="2" bec="0" bev="0" fileid="3" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="4" uspid="0" p8:type="SequencePoint" ordinal="1" offset="1" sc="0" sl="16" ec="1" el="19" bec="0" bev="0" fileid="3" xmlns:p8="xsi" />
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="True" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="4" visitedSequencePoints="4" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Void EnergyAnalyzer.Controllers.WeatherForecastController::.cctor()</Name>
<FileRef uid="3" />
<SequencePoints>
<SequencePoint vc="1" uspid="9" ordinal="0" sl="9" sc="1" el="9" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="10" ordinal="1" sl="10" sc="1" el="10" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="11" ordinal="2" sl="11" sc="1" el="11" ec="2" bec="0" bev="0" fileid="3" />
<SequencePoint vc="1" uspid="12" ordinal="3" sl="12" sc="1" el="12" ec="2" bec="0" bev="0" fileid="3" />
</SequencePoints>
<BranchPoints />
<MethodPoint vc="4" uspid="0" p8:type="SequencePoint" ordinal="2" offset="2" sc="0" sl="9" ec="1" el="12" bec="0" bev="0" fileid="3" xmlns:p8="xsi" />
</Method>
</Methods>
</Class>
</Classes>
</Module>
</Modules>
</CoverageSession>
31 changes: 31 additions & 0 deletions apps/EnergyAnalyzer/EnergyAnalyzer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnergyAnalyzer", "EnergyAnalyzer.csproj", "{4CDB4CAE-43F7-4141-AE9B-A5652181A68C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnergyAnalyzer.Tests", "EnergyAnalyzer.Tests\EnergyAnalyzer.Tests.csproj", "{852A3BCD-ADED-47C0-9C97-44DC3ADD842F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4CDB4CAE-43F7-4141-AE9B-A5652181A68C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CDB4CAE-43F7-4141-AE9B-A5652181A68C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CDB4CAE-43F7-4141-AE9B-A5652181A68C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CDB4CAE-43F7-4141-AE9B-A5652181A68C}.Release|Any CPU.Build.0 = Release|Any CPU
{852A3BCD-ADED-47C0-9C97-44DC3ADD842F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{852A3BCD-ADED-47C0-9C97-44DC3ADD842F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{852A3BCD-ADED-47C0-9C97-44DC3ADD842F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{852A3BCD-ADED-47C0-9C97-44DC3ADD842F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {766591C1-0883-4222-BEEF-EF47465A40F6}
EndGlobalSection
EndGlobal
Loading

0 comments on commit a47bf22

Please sign in to comment.