using System; using System.Collections.Generic; using Octokit.Response; using Xunit; namespace Octokit.Tests.Models { public class PunchCardTests { [Fact] public void ThrowsExceptionWithNullPunchCardPoints() { Assert.Throws(()=>new PunchCard(null)); } [Fact] public void ThrowsExceptionWhenPunchCardPointsHaveIncorrectFormat() { IList point1 = new []{1,2,3,4,5,6}; IEnumerable> points = new List>{point1}; Assert.Throws(() => new PunchCard(points)); } [Fact] public void DoesNotThrowExceptionWhenPunchPointsHaveCorrectFormat() { IList point1 = new[] { 1, 2, 3}; IEnumerable> points = new List> { point1 }; Assert.DoesNotThrow(() => new PunchCard(points)); } [Fact] public void CanQueryCommitsForDayAndHour() { IList point1 = new[] { 1, 0, 3 }; IList point2 = new[] { 1, 1, 4 }; IList point3 = new[] { 1, 2, 0 }; IEnumerable> points = new List> { 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); } } }