Skip to content

Commit

Permalink
Mock LiceCount weekly Post to Mattilsynet
Browse files Browse the repository at this point in the history
  • Loading branch information
ambosch committed Oct 8, 2024
1 parent 5772d4f commit ba559d0
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ override.tf.json
*_override.tf
*_override.tf.json

**.DotSettings.user

# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info

Expand Down
27 changes: 27 additions & 0 deletions api/AquaApi.Tests/AquaApi.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AquaApi\AquaApi.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions api/AquaApi.Tests/MattilsynetServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AquaApi.Application;

namespace AquaApi.Tests;

public class MattilsynetServiceTests
{
[Fact]
public async Task PostLiceCount_ShouldReturnSuccess()
{
// Act
var client = new MockMattilsynetClient();
var service = new MattilsynetService(client);
var result = await service.PostLiceCount();

// Assert
Assert.True(result);
}
}
18 changes: 18 additions & 0 deletions api/AquaApi/Application/MattilsynetService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AquaApi.Domain;

namespace AquaApi.Application;

public class MattilsynetService(IMattilsynetClient client)
{
public async Task<bool> PostLiceCount()
{
var liceCount = new LiceCount
{
VoksneHunnlus = 11,
BevegeligeLus = 4,
FastsittendeLus = 1,
};
var response = await client.PostLiceCount(liceCount);
return response.IsSuccessStatusCode;
}
}
7 changes: 0 additions & 7 deletions api/AquaApi/AquaApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.1" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions api/AquaApi/Domain/LiceCount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace AquaApi.Domain;

public class LiceCount
{
public double VoksneHunnlus { get; set; }
public double BevegeligeLus { get; set; }
public double FastsittendeLus { get; set; }


}
8 changes: 8 additions & 0 deletions api/AquaApi/Infrastructure/IMattilsynetClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using AquaApi.Domain;

namespace AquaApi;

public interface IMattilsynetClient
{
Task<HttpResponseMessage> PostLiceCount(LiceCount liceCount);
}
13 changes: 13 additions & 0 deletions api/AquaApi/Infrastructure/MockMattilsynetClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Net;
using AquaApi.Domain;

namespace AquaApi;

public class MockMattilsynetClient : IMattilsynetClient
{
public async Task<HttpResponseMessage> PostLiceCount(LiceCount liceCount)
{
await Task.Delay(200);
return new HttpResponseMessage(HttpStatusCode.Created);
}
}
34 changes: 0 additions & 34 deletions api/AquaApi/MattilsynetService.cs

This file was deleted.

30 changes: 0 additions & 30 deletions api/AquaApi/tests/MattilsynetServiceTests.cs

This file was deleted.

7 changes: 7 additions & 0 deletions dataplatform-aquaculture-template.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{A6ED9EDF-D59
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AquaApi", "api\AquaApi\AquaApi.csproj", "{35950192-252F-44A8-B710-63E470A67118}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AquaApi.Tests", "api\AquaApi.Tests\AquaApi.Tests.csproj", "{A0796727-D372-4CE1-B11C-3C864835EE4B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,12 +19,17 @@ Global
{35950192-252F-44A8-B710-63E470A67118}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35950192-252F-44A8-B710-63E470A67118}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35950192-252F-44A8-B710-63E470A67118}.Release|Any CPU.Build.0 = Release|Any CPU
{A0796727-D372-4CE1-B11C-3C864835EE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0796727-D372-4CE1-B11C-3C864835EE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0796727-D372-4CE1-B11C-3C864835EE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0796727-D372-4CE1-B11C-3C864835EE4B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{35950192-252F-44A8-B710-63E470A67118} = {A6ED9EDF-D599-47B8-A6B2-2844E3FEBF9C}
{A0796727-D372-4CE1-B11C-3C864835EE4B} = {A6ED9EDF-D599-47B8-A6B2-2844E3FEBF9C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {00A64A12-39CC-40EA-996D-79EA6539A35B}
Expand Down

0 comments on commit ba559d0

Please sign in to comment.