-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from brenordv/feat/latest-glucose
[feat] Updated the endpoint that returns the latest glucose reading.
- Loading branch information
Showing
16 changed files
with
319 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Raccoon.Ninja.AzFn.DataApi.Tests/ExtensionMethods/HttpRequestExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using FluentAssertions; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Primitives; | ||
using Raccoon.Ninja.AzFn.DataApi.ExtensionMethods; | ||
|
||
namespace Raccoon.Ninja.AzFn.DataApi.Tests.ExtensionMethods; | ||
|
||
public class HttpRequestExtensionsTests | ||
{ | ||
[Fact] | ||
public void TryGetReadSinceParam_NoParameter_ReturnsNull() | ||
{ | ||
// Arrange | ||
var context = new DefaultHttpContext(); | ||
var request = context.Request; | ||
|
||
// Act | ||
var result = request.TryGetReadSinceParam(); | ||
|
||
// Assert | ||
result.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void TryGetReadSinceParam_InvalidParameter_ReturnsNull() | ||
{ | ||
// Arrange | ||
var context = new DefaultHttpContext(); | ||
var request = context.Request; | ||
request.QueryString = new QueryString("?readSince=notANumber"); | ||
|
||
// Act | ||
var result = request.TryGetReadSinceParam(); | ||
|
||
// Assert | ||
result.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void TryGetReadSinceParam_ValidParameter_ReturnsLongValue() | ||
{ | ||
// Arrange | ||
var context = new DefaultHttpContext(); | ||
var request = context.Request; | ||
request.QueryString = new QueryString("?readSince=123456"); | ||
|
||
// Act | ||
var result = request.TryGetReadSinceParam(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Should().Be(123456L); | ||
} | ||
|
||
[Fact] | ||
public void TryGetReadSinceParam_ValidParameterSetThroughQueryProperty_ReturnsLongValue() | ||
{ | ||
// Arrange | ||
var context = new DefaultHttpContext(); | ||
var request = context.Request; | ||
|
||
// Setting Query directly using a dictionary. | ||
// Although Query is read-only, we can reassign it using the constructor of QueryCollection. | ||
var queryDictionary = new Dictionary<string, StringValues> | ||
{ | ||
{ "readSince", "987654" } | ||
}; | ||
request.QueryString = QueryString.Create(queryDictionary); | ||
|
||
// Act | ||
var result = request.TryGetReadSinceParam(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Should().Be(987654L); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Raccoon.Ninja.AzFn.DataApi.Tests/Raccoon.Ninja.AzFn.DataApi.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<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="FluentAssertions" Version="6.12.2"/> | ||
<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="..\Raccoon.Ninja.AzFn.DataApi\Raccoon.Ninja.AzFn.DataApi.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Raccoon.Ninja.AzFn.DataApi/ExtensionMethods/HttpRequestExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Raccoon.Ninja.AzFn.DataApi.ExtensionMethods; | ||
|
||
public static class HttpRequestExtensions | ||
{ | ||
public static long? TryGetReadSinceParam(this HttpRequest req) | ||
{ | ||
if (!req.Query.ContainsKey("readSince")) return null; | ||
|
||
if (long.TryParse(req.Query["readSince"], out var readSince)) | ||
return readSince; | ||
|
||
return null; | ||
} | ||
} |
66 changes: 33 additions & 33 deletions
66
Raccoon.Ninja.AzFn.DataApi/Raccoon.Ninja.AzFn.DataApi.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<AssemblyVersion>3.0.0</AssemblyVersion> | ||
<FileVersion>3.0.0</FileVersion> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enabled</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Raccoon.Ninja.Domain.Core\Raccoon.Ninja.Domain.Core.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.9.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" /> | ||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<AssemblyVersion>4.0.0</AssemblyVersion> | ||
<FileVersion>4.0.0</FileVersion> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enabled</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Raccoon.Ninja.Domain.Core\Raccoon.Ninja.Domain.Core.csproj"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.9.0"/> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0"/> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2"/> | ||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0"/> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0"/> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2"/> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.