Skip to content

Commit

Permalink
added HourglassClientTests
Browse files Browse the repository at this point in the history
  • Loading branch information
RickOlaf committed Aug 16, 2024
1 parent dc8a163 commit 5135ef8
Showing 1 changed file with 43 additions and 0 deletions.
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);
}
}
}

0 comments on commit 5135ef8

Please sign in to comment.