public async Task GetMessages_MemberJoinedTeam_ScrumMasterGetsMessage() { // Arrange var team = CreateBasicTeam(); var member = team.Join(MemberName, false); var teamLock = CreateTeamLock(team); var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); planningPoker.Setup(p => p.GetScrumTeam(TeamName)).Returns(teamLock.Object).Verifiable(); planningPoker.Setup(p => p.GetMessagesAsync(team.ScrumMaster, It.IsAny <CancellationToken>())) .ReturnsAsync(() => team.ScrumMaster.Messages.ToList()).Verifiable(); var target = new PlanningPokerService(planningPoker.Object); // Act var result = await target.GetMessages(TeamName, ScrumMasterName, 0, default(CancellationToken)); // Verify planningPoker.Verify(); teamLock.Verify(); Assert.IsNotNull(result); Assert.AreEqual <int>(1, result.Count); Assert.AreEqual <long>(1, result[0].Id); Assert.AreEqual <MessageType>(MessageType.MemberJoined, result[0].Type); Assert.IsInstanceOfType(result[0], typeof(MemberMessage)); var memberMessage = (MemberMessage)result[0]; Assert.IsNotNull(memberMessage.Member); Assert.AreEqual <string>(MemberName, memberMessage.Member.Name); }
public async Task GetMessages_MemberNameTooLong_ArgumentException() { // Arrange var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); var target = new PlanningPokerService(planningPoker.Object); // Act await target.GetMessages(TeamName, LongMemberName, 0, default(CancellationToken)); }
public async Task GetMessages_TeamNameTooLong_ArgumentException() { // Arrange var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); var target = new PlanningPokerService(planningPoker.Object); // Act await target.GetMessages(LongTeamName, MemberName, 0); }
public async Task GetMessages_MemberNameIsEmpty_ArgumentNullException() { // Arrange var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); var target = new PlanningPokerService(planningPoker.Object); // Act await target.GetMessages(TeamName, null, 0); }
public async Task GetMessages_EstimationEnded_ScrumMasterGetsMessages() { // Arrange var team = CreateBasicTeam(); var member = (D.Member)team.Join(MemberName, false); var master = team.ScrumMaster; master.StartEstimation(); master.Estimation = new D.Estimation(1.0); member.Estimation = new D.Estimation(2.0); var teamLock = CreateTeamLock(team); var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); planningPoker.Setup(p => p.GetScrumTeam(TeamName)).Returns(teamLock.Object).Verifiable(); planningPoker.Setup(p => p.GetMessagesAsync(master, It.IsAny <CancellationToken>())) .ReturnsAsync(() => master.Messages.ToList()).Verifiable(); var target = new PlanningPokerService(planningPoker.Object); // Act var result = await target.GetMessages(TeamName, ScrumMasterName, 1, default(CancellationToken)); // Verify planningPoker.Verify(); teamLock.Verify(); Assert.IsNotNull(result); Assert.AreEqual <int>(4, result.Count); Assert.AreEqual <long>(2, result[0].Id); Assert.AreEqual <MessageType>(MessageType.EstimationStarted, result[0].Type); Assert.AreEqual <long>(3, result[1].Id); Assert.AreEqual <MessageType>(MessageType.MemberEstimated, result[1].Type); Assert.AreEqual <long>(4, result[2].Id); Assert.AreEqual <MessageType>(MessageType.MemberEstimated, result[2].Type); Assert.AreEqual <long>(5, result[3].Id); Assert.AreEqual <MessageType>(MessageType.EstimationEnded, result[3].Type); Assert.IsInstanceOfType(result[3], typeof(EstimationResultMessage)); var estimationResultMessage = (EstimationResultMessage)result[3]; Assert.IsNotNull(estimationResultMessage.EstimationResult); var expectedResult = new Tuple <string, double>[] { new Tuple <string, double>(ScrumMasterName, 1.0), new Tuple <string, double>(MemberName, 2.0) }; CollectionAssert.AreEquivalent(expectedResult, estimationResultMessage.EstimationResult.Select(i => new Tuple <string, double>(i.Member.Name, i.Estimation.Value.Value)).ToList()); }
public async Task GetMessages_NoMessagesOnTime_ReturnsEmptyCollection() { // Arrange var team = CreateBasicTeam(); var teamLock = CreateTeamLock(team); var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); planningPoker.Setup(p => p.GetScrumTeam(TeamName)).Returns(teamLock.Object).Verifiable(); planningPoker.Setup(p => p.GetMessagesAsync(team.ScrumMaster, It.IsAny <CancellationToken>())) .ReturnsAsync(Enumerable.Empty <D.Message>()).Verifiable(); var target = new PlanningPokerService(planningPoker.Object); // Act var result = await target.GetMessages(TeamName, ScrumMasterName, 0, default(CancellationToken)); // Verify planningPoker.Verify(); Assert.IsNotNull(result); Assert.AreEqual <int>(0, result.Count); }
public async Task GetMessages_NoMessagesOnTime_ReturnsEmptyCollection() { // Arrange var team = CreateBasicTeam(); var teamLock = CreateTeamLock(team); var planningPoker = new Mock <D.IPlanningPoker>(MockBehavior.Strict); planningPoker.Setup(p => p.GetScrumTeam(TeamName)).Returns(teamLock.Object).Verifiable(); planningPoker.Setup(p => p.GetMessagesAsync(team.ScrumMaster, It.IsAny <Action <bool, D.Observer> >())) .Callback <D.Observer, Action <bool, D.Observer> >((o, c) => c(false, null)).Verifiable(); var target = new PlanningPokerService(planningPoker.Object); // Act var result = await target.GetMessages(TeamName, ScrumMasterName, 0); // Verify planningPoker.Verify(); Assert.IsNotNull(result); Assert.AreEqual <int>(0, result.Count); }