public void StartEstimation_EstimationNotStarted_ScrumMasterGotMessageEstimationStarted() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); // Act master.StartEstimation(); // Verify Assert.IsTrue(master.HasMessage); var message = master.PopMessage(); Assert.IsNotNull(message); Assert.AreEqual <MessageType>(MessageType.EstimationStarted, message.MessageType); Assert.IsFalse(master.HasMessage); }
public void InitializeScrumTeam_TeamSpecified_TeamCreatedMessageIsNotSent() { // Arrange var target = CreateAzurePlanningPokerController(); var team = new ScrumTeam("team"); target.SetTeamsInitializingList(new string[] { "team" }); ScrumTeamMessage message = null; target.ObservableMessages.Subscribe(m => message = m); // Act target.InitializeScrumTeam(team); // Verify Assert.IsNull(message); }
public void Join_AsMemberWhenObserverExists_ObserverGetMemberJoinedMessage() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); var observer = target.Join("observer", true); // Act var result = target.Join("member", false); // Verify Assert.IsTrue(observer.HasMessage); var message = observer.PopMessage(); Assert.AreEqual <MessageType>(MessageType.MemberJoined, message.MessageType); Assert.IsFalse(observer.HasMessage); }
public void CancelEstimation_EstimationInProgress_ScrumMasterMessageReceived() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); master.StartEstimation(); EventArgs eventArgs = null; master.MessageReceived += new EventHandler((s, e) => eventArgs = e); // Act master.CancelEstimation(); // Verify Assert.IsNotNull(eventArgs); }
public void Join_EstimationStarted_OnlyScrumMasterIsInEstimationParticipants() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); master.StartEstimation(); // Act var member = (Member)target.Join("member", false); var result = target.EstimationParticipants; // Verify Assert.IsNotNull(result); Assert.AreEqual <int>(1, result.Count()); Assert.AreEqual <string>(master.Name, result.First().MemberName); }
public void Join_AsMember_ScrumMasterGetMessageWithMember() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); // Act var result = target.Join("member", false); // Verify var message = master.PopMessage(); Assert.IsInstanceOfType(message, typeof(MemberMessage)); var memberMessage = (MemberMessage)message; Assert.AreEqual <Observer>(result, memberMessage.Member); }
public void EstimationParticipants_EstimationStarted_ReturnsScrumMaster() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); master.StartEstimation(); // Act var result = target.EstimationParticipants; // Verify Assert.IsNotNull(result); Assert.AreEqual <int>(1, result.Count()); Assert.AreEqual <string>(master.Name, result.First().MemberName); Assert.IsFalse(result.First().Estimated); }
public void FindMemberOrObserver_MemberNorObserverExists_ReturnsNull() { // Arrange var name = "test"; var target = new ScrumTeam("test team"); target.Join("observer1", true); target.Join("observer2", true); target.Join("member1", false); target.Join("member2", false); // Act var result = target.FindMemberOrObserver(name); // Verify Assert.IsNull(result); }
public void Disconnect_AsMemberWhenObserverExists_ObserverMessageReceived() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); var member = target.Join("member", false); var observer = target.Join("observer", true); EventArgs eventArgs = null; observer.MessageReceived += new EventHandler((s, e) => eventArgs = e); // Act target.Disconnect(member.Name); // Verify Assert.IsNotNull(eventArgs); }
public void Disconnect_AsMember_MemberGetsEmptyMessage() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); var member = target.Join("member", false); // Act target.Disconnect(member.Name); // Verify Assert.IsTrue(member.HasMessage); var message = member.PopMessage(); Assert.AreEqual <MessageType>(MessageType.Empty, message.MessageType); Assert.IsFalse(member.HasMessage); }
/// <summary> /// Joins existing Scrum Team and initialize Planning Poker game. /// </summary> /// <param name="teamName">Name of the team.</param> /// <param name="memberName">Name of the joining member.</param> /// <param name="asObserver"><c>True</c> if member is joining as observer only; otherwise <c>false</c>.</param> /// <returns><c>True</c> if the operation was successful; otherwise <c>false</c>.</returns> public async Task <bool> JoinTeam(string teamName, string memberName, bool asObserver) { if (string.IsNullOrEmpty(teamName) || string.IsNullOrEmpty(memberName)) { return(false); } try { ScrumTeam team = null; using (_busyIndicatorService.Show()) { team = await _planningPokerService.JoinTeam(teamName, memberName, asObserver, CancellationToken.None); } if (team != null) { await _planningPokerInitializer.InitializeTeam(team, memberName); ControllerHelper.OpenPlanningPokerPage(_uriHelper, team, memberName); return(true); } } catch (PlanningPokerException ex) { var message = ex.Message; if (message.IndexOf(MemberExistsError1, StringComparison.OrdinalIgnoreCase) >= 0 && message.IndexOf(MemberExistsError2, StringComparison.OrdinalIgnoreCase) >= 0) { message = ControllerHelper.GetErrorMessage(ex); message = $"{message}{Environment.NewLine}{Resources.JoinTeam_ReconnectMessage}"; if (await _messageBoxService.ShowMessage(message, Resources.JoinTeam_ReconnectTitle, Resources.JoinTeam_ReconnectButton)) { return(await ReconnectTeam(teamName, memberName, false, CancellationToken.None)); } } else { message = ControllerHelper.GetErrorMessage(ex); await _messageBoxService.ShowMessage(message, Resources.MessagePanel_Error); } } return(false); }
public void StartEstimation_EstimationNotStarted_ObserverGotMessageEstimationStarted() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); var observer = team.Join("observer", true); // Act master.StartEstimation(); // Verify Assert.IsTrue(observer.HasMessage); Assert.AreEqual(1, observer.Messages.Count()); var message = observer.Messages.First(); Assert.IsNotNull(message); Assert.AreEqual <MessageType>(MessageType.EstimationStarted, message.MessageType); }
public void SerializeAndDeserialize_MemberMessageReceivedEventHandler_NoMessageReceivedEventHandler() { // Arrange var team = new ScrumTeam("test"); var master = team.SetScrumMaster("master"); int eventsCount = 0; master.MessageReceived += new EventHandler((s, e) => eventsCount++); // Act var bytes = SerializeTeam(team); var result = DeserializeTeam(bytes); // Verify eventsCount = 0; result.ScrumMaster.StartEstimation(); Assert.AreEqual <int>(0, eventsCount); }
public void SerializeAndDeserialize_EstimationEnded_CopyOfTheTeam() { // Arrange var team = new ScrumTeam("test"); var master = team.SetScrumMaster("master"); var member = (Member)team.Join("member", false); team.Join("observer", true); master.StartEstimation(); team.Join("Bob", true); team.Join("Alice", false); member.Estimation = team.AvailableEstimations.Single(e => e.Value == 0.5); master.Estimation = team.AvailableEstimations.Single(e => e.Value.HasValue && double.IsPositiveInfinity(e.Value.Value)); // Act // Verify VerifySerialization(team); }
public void ClearMessages_After2Messages_HasNoMessages() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); var target = team.Join("test", true); master.StartEstimation(); master.CancelEstimation(); // Act var result = target.ClearMessages(); // Verify Assert.AreEqual <long>(2, result); Assert.IsFalse(target.HasMessage); Assert.AreEqual <long>(result, target.AcknowledgedMessageId); }
public void FindMemberOrObserver_MemberExists_ReturnsMember() { // Arrange var name = "member2"; var target = new ScrumTeam("test team"); target.Join("observer1", true); target.Join("observer2", true); target.Join("member1", false); target.Join("member2", false); // Act var result = target.FindMemberOrObserver(name); // Verify Assert.IsNotNull(result); Assert.AreEqual <string>(name, result.Name); }
public void Estimation_SetOnAllMembers_StateChangedToEstimationFinished() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); var member = (Member)team.Join("member", false); master.StartEstimation(); var masterEstimation = new Estimation(); var memberEstimation = new Estimation(); // Act master.Estimation = masterEstimation; member.Estimation = memberEstimation; // Verify Assert.AreEqual <TeamState>(TeamState.EstimationFinished, team.State); }
private static void AssertAvailableEstimations(ScrumTeam scrumTeam) { Assert.AreEqual(13, scrumTeam.AvailableEstimations.Count); Assert.AreEqual(0.0, scrumTeam.AvailableEstimations[0].Value); Assert.AreEqual(0.5, scrumTeam.AvailableEstimations[1].Value); Assert.AreEqual(1.0, scrumTeam.AvailableEstimations[2].Value); Assert.AreEqual(2.0, scrumTeam.AvailableEstimations[3].Value); Assert.AreEqual(3.0, scrumTeam.AvailableEstimations[4].Value); Assert.AreEqual(5.0, scrumTeam.AvailableEstimations[5].Value); Assert.AreEqual(8.0, scrumTeam.AvailableEstimations[6].Value); Assert.AreEqual(13.0, scrumTeam.AvailableEstimations[7].Value); Assert.AreEqual(20.0, scrumTeam.AvailableEstimations[8].Value); Assert.AreEqual(40.0, scrumTeam.AvailableEstimations[9].Value); Assert.AreEqual(100.0, scrumTeam.AvailableEstimations[10].Value); Assert.AreEqual(100.0, scrumTeam.AvailableEstimations[10].Value); Assert.IsTrue(double.IsPositiveInfinity(scrumTeam.AvailableEstimations[11].Value.Value)); Assert.IsNull(scrumTeam.AvailableEstimations[12].Value); }
/// <summary> /// Saves the Scrum team to repository. /// </summary> /// <param name="team">The Scrum team.</param> public void SaveScrumTeam(ScrumTeam team) { if (team == null) { throw new ArgumentNullException("team"); } this.InitializeFolder(); string file = this.GetFileName(team.Name); file = Path.Combine(this.Folder, file); using (var stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)) { this.SerializeScrumTeam(team, stream); } }
public void AttachScrumTeam_TeamNotInRepository_TriedToLoadFromRepository() { // Arrange var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict); repository.Setup(r => r.LoadScrumTeam("team")).Returns((ScrumTeam)null); var team = new ScrumTeam("team"); var target = CreatePlanningPokerController(repository: repository.Object); // Act using (var teamLock = target.AttachScrumTeam(team)) { // Verify Assert.IsNotNull(teamLock); repository.Verify(r => r.LoadScrumTeam("team"), Times.Once()); } }
public void Serialize(TextWriter writer, ScrumTeam scrumTeam) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (scrumTeam == null) { throw new ArgumentNullException(nameof(scrumTeam)); } var data = scrumTeam.GetData(); var serializer = JsonSerializer.Create(); serializer.ContractResolver = _contractResolver; serializer.Serialize(writer, data); }
public void SerializeAndDeserialize_TeamWithObserver_CopyOfTheTeam() { // Arrange var team = new ScrumTeam("test"); team.SetScrumMaster("master"); var observer = team.Join("member", true); // Act var bytes = SerializeTeam(team); var result = DeserializeTeam(bytes); // Verify Assert.AreEqual <int>(1, result.Observers.Count()); var resultObserver = result.Observers.First(); Assert.AreEqual <string>(observer.Name, resultObserver.Name); Assert.AreEqual <DateTime>(observer.LastActivity, resultObserver.LastActivity); }
public void AttachScrumTeam_TeamNotInRepository_TriedToLoadFromRepository() { // Arrange var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict); repository.Setup(r => r.LoadScrumTeam("team")).Returns((ScrumTeam)null); var availableEstimations = DeckProvider.Default.GetDeck(Deck.Fibonacci); var team = new ScrumTeam("team", availableEstimations, null, null); var target = CreatePlanningPokerController(repository: repository.Object); // Act using (var teamLock = target.AttachScrumTeam(team)) { // Verify Assert.IsNotNull(teamLock); repository.Verify(r => r.LoadScrumTeam("team"), Times.Once()); } }
public void Constructor_ScrumMasterAndMember_MembersHasNoEstimation() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); var member = (Member)team.Join("member", false); // Act var result = new EstimationResult(new Member[] { master, member }); // Verify var expectedResult = new KeyValuePair <Member, Estimation>[] { new KeyValuePair <Member, Estimation>(member, null), new KeyValuePair <Member, Estimation>(master, null), }; CollectionAssert.AreEquivalent(expectedResult, result.ToList()); }
public void StartEstimation_EstimationNotStarted_ScrumTeamGotMessageEstimationStarted() { // Arrange var team = new ScrumTeam("test team"); var master = team.SetScrumMaster("master"); MessageReceivedEventArgs eventArgs = null; team.MessageReceived += new EventHandler <MessageReceivedEventArgs>((s, e) => eventArgs = e); // Act master.StartEstimation(); // Verify Assert.IsNotNull(eventArgs); var message = eventArgs.Message; Assert.IsNotNull(message); Assert.AreEqual <MessageType>(MessageType.EstimationStarted, message.MessageType); }
public void Disconnect_AsMember_ScrumTeamGetMemberDisconnectedMessage() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); var member = target.Join("member", false); MessageReceivedEventArgs eventArgs = null; target.MessageReceived += new EventHandler <MessageReceivedEventArgs>((s, e) => eventArgs = e); // Act target.Disconnect(member.Name); // Verify Assert.IsNotNull(eventArgs); var message = eventArgs.Message; Assert.AreEqual <MessageType>(MessageType.MemberDisconnected, message.MessageType); }
public void CreateScrumTeam_EmptyTeamInRepository_CreatesNewTeamAndDeletesOldOne() { // Arrange var team = new ScrumTeam("team"); var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict); repository.Setup(r => r.LoadScrumTeam("team")).Returns(team); repository.Setup(r => r.DeleteScrumTeam("team")); var target = CreatePlanningPokerController(repository: repository.Object); // Act using (var teamLock = target.CreateScrumTeam("team", "master")) { // Verify Assert.AreNotEqual <ScrumTeam>(team, teamLock.Team); repository.Verify(r => r.LoadScrumTeam("team"), Times.Once()); repository.Verify(r => r.DeleteScrumTeam("team"), Times.Once()); } }
public void Disconnect_AsMemberWhenObserverExists_ObserverGetMessageWithMember() { // Arrange var target = new ScrumTeam("test team"); var master = target.SetScrumMaster("master"); var member = target.Join("member", false); var observer = target.Join("observer", true); // Act target.Disconnect(member.Name); // Verify var message = observer.PopMessage(); Assert.IsInstanceOfType(message, typeof(MemberMessage)); var memberMessage = (MemberMessage)message; Assert.AreEqual <Observer>(member, memberMessage.Member); }
/// <summary> /// Saves the Scrum team to repository. /// </summary> /// <param name="team">The Scrum team.</param> public void SaveScrumTeam(ScrumTeam team) { if (team == null) { throw new ArgumentNullException(nameof(team)); } InitializeFolder(); string file = GetFileName(team.Name); file = Path.Combine(Folder, file); using (var stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)) { SerializeScrumTeam(team, stream); } _logger?.LogDebug(Resources.Repository_Debug_SaveScrumTeam, team.Name); }
public void UpdateActivity_UtcNowIsChanged_LastActivityIsChanged() { // Arrange var utcNow = new DateTime(2012, 1, 2, 4, 50, 13); var dateTimeProvider = new DateTimeProviderMock(); dateTimeProvider.SetUtcNow(new DateTime(2012, 1, 2, 3, 35, 0)); var team = new ScrumTeam("test team", dateTimeProvider); var target = new Observer(team, "test"); dateTimeProvider.SetUtcNow(utcNow); // Act target.UpdateActivity(); var result = target.LastActivity; // Verify Assert.AreEqual <DateTime>(utcNow, result); }