Skip to content

Commit

Permalink
feat: new interface IHourglassClient
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhey authored Aug 16, 2024
2 parents 41954b4 + 5135ef8 commit edfb4cf
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
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);
}
}
}
2 changes: 1 addition & 1 deletion Develappers.RedmineHourglassApi/HourglassClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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)
{
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; }
}
}

0 comments on commit edfb4cf

Please sign in to comment.