mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
* Added a convention test to detect a model constructor exposing all properties * add ctors to classes where they are missing * rename ctor parameters that dont match properties * add missing parameters to existing ctors * add specific PunchCard ctor to allow mocking, and update test to resolve call ambiguity * Added base class properties to the convention test Added member exclusion attribute * Updated newly offending classes 2 excludes and 2 ctors * rename exclusion attribute to be a bit shorter
67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Octokit;
|
|
using Octokit.Tests.Helpers;
|
|
using Xunit;
|
|
|
|
public class PunchCardTests
|
|
{
|
|
public class TheConstructor
|
|
{
|
|
[Fact]
|
|
public void ThrowsExceptionWithNullPunchCardPoints()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => new PunchCard((IEnumerable<IList<int>>)null));
|
|
}
|
|
|
|
[Fact]
|
|
public void ThrowsExceptionWhenPunchCardPointsHaveIncorrectFormat()
|
|
{
|
|
IList<int> point1 = new[] { 1, 2, 3, 4, 5, 6 };
|
|
IEnumerable<IList<int>> points = new List<IList<int>> { point1 };
|
|
Assert.Throws<ArgumentException>(() => new PunchCard(points));
|
|
}
|
|
|
|
[Fact]
|
|
public void DoesNotThrowExceptionWhenPunchPointsHaveCorrectFormat()
|
|
{
|
|
IList<int> point1 = new[] { 1, 2, 3 };
|
|
IEnumerable<IList<int>> points = new List<IList<int>> { point1 };
|
|
var punchcard = new PunchCard(points);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanQueryCommitsForDayAndHour()
|
|
{
|
|
IList<int> point1 = new[] { 1, 0, 3 };
|
|
IList<int> point2 = new[] { 1, 1, 4 };
|
|
IList<int> point3 = new[] { 1, 2, 0 };
|
|
IEnumerable<IList<int>> points = new List<IList<int>> { point1, point2, point3 };
|
|
|
|
var punchCard = new PunchCard(points);
|
|
|
|
var commitsAtMondayAt12Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 0);
|
|
var commitsAtMondayAt1Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 1);
|
|
var commitsAtMondayAt2Am = punchCard.GetCommitCountFor(DayOfWeek.Monday, 2);
|
|
var commitsAtTuesdayAt2Am = punchCard.GetCommitCountFor(DayOfWeek.Tuesday, 2);
|
|
|
|
Assert.Equal(3, commitsAtMondayAt12Am);
|
|
Assert.Equal(4, commitsAtMondayAt1Am);
|
|
Assert.Equal(0, commitsAtMondayAt2Am);
|
|
Assert.Equal(0, commitsAtTuesdayAt2Am);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetsPunchPointsAsReadOnlyDictionary()
|
|
{
|
|
IList<int> point1 = new[] { 1, 0, 3 };
|
|
IList<int> point2 = new[] { 1, 1, 4 };
|
|
IList<int> point3 = new[] { 1, 2, 0 };
|
|
IEnumerable<IList<int>> points = new List<IList<int>> { point1, point2, point3 };
|
|
|
|
var punchCard = new PunchCard(points);
|
|
|
|
AssertEx.IsReadOnlyCollection<PunchCardPoint>(punchCard.PunchPoints);
|
|
}
|
|
}
|
|
} |