Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhey committed Aug 16, 2024
2 parents 9bc6eb0 + edfb4cf commit 66bd21e
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.0.100
- name: Install dependencies
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --filter Category=UnitTest --no-restore --verbosity normal
run: dotnet test --filter Category=UnitTest --no-restore --verbosity normal
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.0.100
- name: Install dependencies
dotnet-version: 8.0.x
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

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

Expand All @@ -11,10 +12,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
43 changes: 43 additions & 0 deletions Develappers.RedmineHourglassApi.Tests/HourglassClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using Xunit;

namespace Develappers.RedmineHourglassApi.Tests
{
public class HourglassClientTests
{
[Fact]
public void ValidConfiguration_ShouldSetProperties()
{
var config = Helpers.GetTestConfiguration();
var hourglassClient = new HourglassClient(config);

Assert.NotNull(hourglassClient.TimeBookings);
Assert.NotNull(hourglassClient.TimeLogs);
Assert.NotNull(hourglassClient.TimeTrackers);
}

[Fact]
public void NullConfiguration_ShouldThrowArgumentNullException()
{
Assert.Throws<ArgumentNullException>(() => new HourglassClient(null));
}

[Fact]
public void InvalidApiKey_ShouldThrowArgumentException()
{
var config = new Configuration("https://redmineTest.de", "");

var exception = Assert.Throws<ArgumentException>(() => new HourglassClient(config));
Assert.Equal("invalid api key (Parameter 'configuration')", exception.Message);
}

[Fact]
public void InvalidRedmineUrl_ShouldThrowArgumentException()
{
var config = new Configuration("", "ApiKey");

var exception = Assert.Throws<ArgumentException>(() => new HourglassClient(config));
Assert.Equal("invalid base url (Parameter 'configuration')", exception.Message);
}
}
}
5 changes: 1 addition & 4 deletions Develappers.RedmineHourglassApi/BaseService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using Develappers.RedmineHourglassApi.Types;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
Expand Down
7 changes: 4 additions & 3 deletions Develappers.RedmineHourglassApi/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Develappers.RedmineHourglassApi
{
Expand All @@ -9,6 +9,7 @@ public Configuration()
{
}

[SetsRequiredMembers]
public Configuration(string redmineUrl, string apiKey)
{
RedmineUrl = redmineUrl;
Expand All @@ -18,12 +19,12 @@ public Configuration(string redmineUrl, string apiKey)
/// <summary>
/// The redmine installation url.
/// </summary>
public string RedmineUrl { get; set; }
public required string RedmineUrl { get; set; }

/// <summary>
/// The api key.
/// </summary>
public string ApiKey { get; set; }
public required string ApiKey { get; set; }

internal Configuration DeepClone()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Develappers.RedmineHourglassApi</AssemblyName>
<RootNamespace>Develappers.RedmineHourglassApi</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -15,22 +17,19 @@
<RepositoryType>Git</RepositoryType>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/DevelappersGmbH/RedmineHourglassNet/master/icon.png</PackageIconUrl>
<Version>1.2.0</Version>
<Version>2.0.0-alpha</Version>
<RepositoryUrl>https://github.com/DevelappersGmbH/RedmineHourglassNet.git</RepositoryUrl>
<PackageReleaseNotes></PackageReleaseNotes>
<LangVersion>default</LangVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions Develappers.RedmineHourglassApi/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.IO;
using System.Net;
using System.Net;
using Develappers.RedmineHourglassApi.Types;
using Newtonsoft.Json;

Expand Down
7 changes: 3 additions & 4 deletions Develappers.RedmineHourglassApi/HourglassClient.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

namespace Develappers.RedmineHourglassApi
{
/// <summary>
/// Central object to access the API.
/// </summary>
public class HourglassClient
public class HourglassClient : IHourglassClient
{
public HourglassClient(Configuration configuration, ILogger logger = null)
public HourglassClient(Configuration configuration, ILogger? logger = null)
{
logger ??= NullLogger.Instance;

Expand Down
6 changes: 1 addition & 5 deletions Develappers.RedmineHourglassApi/HttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.IO;
using System.Net;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Develappers.RedmineHourglassApi;
Expand Down
9 changes: 9 additions & 0 deletions Develappers.RedmineHourglassApi/IHourglassClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Develappers.RedmineHourglassApi
{
public interface IHourglassClient
{
ITimeBookingService TimeBookings { get; }
ITimeLogService TimeLogs { get; }
ITimeTrackerService TimeTrackers { get; }
}
}
7 changes: 2 additions & 5 deletions Develappers.RedmineHourglassApi/ITimeBookingService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Develappers.RedmineHourglassApi.Types;
using Develappers.RedmineHourglassApi.Types;

namespace Develappers.RedmineHourglassApi;

Expand All @@ -16,7 +13,7 @@ public interface ITimeBookingService
Task<PaginatedResult<TimeBooking>> GetListAsync(TimeBookingListQuery query, CancellationToken token = default);

/// <summary>
/// Retrieves a time booking by it's id.
/// Retrieves a time booking by its id.
/// </summary>
/// <param name="id">The id of the time booking.</param>
/// <param name="token">The cancellation token.</param>
Expand Down
6 changes: 1 addition & 5 deletions Develappers.RedmineHourglassApi/ITimeLogService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Develappers.RedmineHourglassApi.Types;
using Develappers.RedmineHourglassApi.Types;

namespace Develappers.RedmineHourglassApi;

Expand Down
5 changes: 1 addition & 4 deletions Develappers.RedmineHourglassApi/ITimeTrackerService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Develappers.RedmineHourglassApi.Types;
using Develappers.RedmineHourglassApi.Types;

namespace Develappers.RedmineHourglassApi;

Expand Down
9 changes: 1 addition & 8 deletions Develappers.RedmineHourglassApi/NotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Develappers.RedmineHourglassApi;
namespace Develappers.RedmineHourglassApi;

public class NotFoundException : Exception
{
Expand All @@ -16,8 +13,4 @@ public NotFoundException(string message) : base(message)
public NotFoundException(string message, Exception innerException) : base(message, innerException)
{
}

protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
5 changes: 0 additions & 5 deletions Develappers.RedmineHourglassApi/TimeBookingService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using Develappers.RedmineHourglassApi.Types;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Develappers.RedmineHourglassApi;

Expand Down
10 changes: 0 additions & 10 deletions Develappers.RedmineHourglassApi/TimeLogService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Develappers.RedmineHourglassApi.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Develappers.RedmineHourglassApi;
Expand Down Expand Up @@ -148,11 +143,6 @@ public async Task BulkBookAsync(List<TimeBookingBulkUpdate> values, Cancellation
throw new ArgumentNullException(nameof(values));
}

if (values == null)
{
throw new ArgumentNullException(nameof(values));
}

var dict = new Dictionary<string, TimeBookingBulkUpdate>();
for (var i = 0; i < values.Count; i++)
{
Expand Down
5 changes: 0 additions & 5 deletions Develappers.RedmineHourglassApi/TimeTrackerService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using Develappers.RedmineHourglassApi.Types;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Develappers.RedmineHourglassApi;
Expand Down

0 comments on commit 66bd21e

Please sign in to comment.