Пример #1
0
        public async Task ProcessMessages_MemberJoinedWithMember_2Members()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ScrumMasterName);

            var message = new MemberMessage
            {
                Id     = 0,
                Type   = MessageType.MemberJoined,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "New member"
                }
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(0, target.LastMessageId);
            var expectedMembers = new string[] { "New member", PlanningPokerData.MemberName };

            CollectionAssert.AreEqual(expectedMembers, target.Members.ToList());
            expectedMembers = new string[] { PlanningPokerData.ObserverName };
            CollectionAssert.AreEqual(expectedMembers, target.Observers.ToList());
        }
Пример #2
0
        public async Task ProcessMessages_MemberDisconnectedWithNotExistingName_NoChanges()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.State = TeamState.EstimationCanceled;
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.MemberName);

            var message = new MemberMessage
            {
                Id     = 0,
                Type   = MessageType.MemberDisconnected,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "Disconnect"
                }
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(0, target.LastMessageId);
            Assert.AreEqual(PlanningPokerData.ScrumMasterName, target.ScrumMaster);
            var expectedMembers = new string[] { PlanningPokerData.MemberName };

            CollectionAssert.AreEqual(expectedMembers, target.Members.ToList());
            expectedMembers = new string[] { PlanningPokerData.ObserverName };
            CollectionAssert.AreEqual(expectedMembers, target.Observers.ToList());
        }
Пример #3
0
        public async Task ProcessMessages_MemberEstimatedWithScrumMaster_1Estimation()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ObserverName);

            var message = new MemberMessage
            {
                Id     = 4,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.ScrumMasterType,
                    Name = PlanningPokerData.ScrumMasterName
                }
            };

            StartEstimation(target);
            ProcessMessage(target, message);

            Assert.AreEqual(2, propertyChangedCounter.Count);
            Assert.AreEqual(4, target.LastMessageId);
            Assert.IsFalse(target.CanSelectEstimation);
            Assert.IsFalse(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);

            Assert.AreEqual(1, target.Estimations.Count());
            var estimation = target.Estimations.First();

            Assert.AreEqual(PlanningPokerData.ScrumMasterName, estimation.MemberName);
            Assert.IsFalse(estimation.HasEstimation);
        }
Пример #4
0
        public async Task ProcessMessages_EstimationCanceled_StateIsEstimationCanceled()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.State = TeamState.EstimationInProgress;
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(CreateTeamResult(scrumTeam), PlanningPokerData.ScrumMasterName);

            var message = new Message
            {
                Id   = 4,
                Type = MessageType.EstimationCanceled
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(4, target.LastMessageId);
            Assert.AreEqual(TeamState.EstimationCanceled, target.ScrumTeam.State);
            Assert.IsFalse(target.CanSelectEstimation);
            Assert.IsTrue(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);
            PlanningPokerControllerTest.AssertNoMemberHasEstimated(target);
        }
Пример #5
0
        public async Task ProcessMessages_MemberDisconnectedWithObserver_0Observers()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(CreateTeamResult(scrumTeam), PlanningPokerData.MemberName);

            var message = new MemberMessage
            {
                Id     = 1,
                Type   = MessageType.MemberDisconnected,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.ObserverType,
                    Name = PlanningPokerData.ObserverName
                }
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(1, target.LastMessageId);
            Assert.AreEqual(PlanningPokerData.ScrumMasterName, target.ScrumMaster.Name);
            var expectedMembers = new string[] { PlanningPokerData.MemberName };

            CollectionAssert.AreEqual(expectedMembers, target.Members.Select(m => m.Name).ToList());
            expectedMembers = Array.Empty <string>();
            CollectionAssert.AreEqual(expectedMembers, target.Observers.Select(m => m.Name).ToList());
            PlanningPokerControllerTest.AssertNoMemberHasEstimated(target);
        }
Пример #6
0
        public async Task ProcessMessages_MemberJoinedWithObserver_1Observer()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.Observers = null;
            scrumTeam.State     = TeamState.EstimationFinished;
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(CreateTeamResult(scrumTeam), PlanningPokerData.MemberName);

            var message = new MemberMessage
            {
                Id     = 1,
                Type   = MessageType.MemberJoined,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.ObserverType,
                    Name = "New observer"
                }
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(1, target.LastMessageId);
            var expectedMembers = new string[] { PlanningPokerData.MemberName };

            CollectionAssert.AreEqual(expectedMembers, target.Members.Select(m => m.Name).ToList());
            expectedMembers = new string[] { "New observer" };
            CollectionAssert.AreEqual(expectedMembers, target.Observers.Select(m => m.Name).ToList());
            PlanningPokerControllerTest.AssertNoMemberHasEstimated(target);
        }
Пример #7
0
        public async Task ProcessMessages_Null_ArgumentNullException()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ScrumMasterName);

            Assert.ThrowsException <ArgumentNullException>(() => target.ProcessMessages(null));
        }
Пример #8
0
        public async Task ProcessMessages_EmptyCollection_LastMessageIdIsNotUpdated()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ScrumMasterName);

            target.ProcessMessages(Enumerable.Empty <Message>());

            Assert.AreEqual(0, propertyChangedCounter.Count);
            Assert.AreEqual(-1, target.LastMessageId);
        }
Пример #9
0
        public async Task ProcessMessages_2xMemberEstimated_2Estimations()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(CreateTeamResult(scrumTeam), PlanningPokerData.MemberName);

            var message1 = new MemberMessage
            {
                Id     = 5,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.ScrumMasterType,
                    Name = PlanningPokerData.ScrumMasterName
                }
            };
            var message2 = new MemberMessage
            {
                Id     = 6,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = PlanningPokerData.MemberName
                }
            };

            StartEstimation(target);
            target.ProcessMessages(new Message[] { message2, message1 });

            Assert.AreEqual(3, propertyChangedCounter.Count);
            Assert.AreEqual(6, target.LastMessageId);
            Assert.IsTrue(target.CanSelectEstimation);
            Assert.IsFalse(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);
            PlanningPokerControllerTest.AssertNoObserverHasEstimated(target);

            var estimations = target.Estimations.ToList();

            Assert.AreEqual(2, estimations.Count);
            var estimation = estimations[0];

            Assert.AreEqual(PlanningPokerData.ScrumMasterName, estimation.MemberName);
            Assert.IsFalse(estimation.HasEstimation);
            estimation = estimations[1];
            Assert.AreEqual(PlanningPokerData.MemberName, estimation.MemberName);
            Assert.IsFalse(estimation.HasEstimation);

            Assert.IsTrue(target.ScrumMaster.HasEstimated);
            PlanningPokerControllerTest.AssertMemberHasEstimated(target, PlanningPokerData.MemberName, true);
        }
Пример #10
0
        private static PlanningPokerController CreateController(PropertyChangedCounter propertyChangedCounter = null)
        {
            var planningPokerClient    = new Mock <IPlanningPokerClient>();
            var busyIndicator          = new Mock <IBusyIndicatorService>();
            var memberCredentialsStore = new Mock <IMemberCredentialsStore>();
            var result = new PlanningPokerController(planningPokerClient.Object, busyIndicator.Object, memberCredentialsStore.Object);

            if (propertyChangedCounter != null)
            {
                // Subtract 1 PropertyChanged event raised by InitializeTeam
                propertyChangedCounter.Count  = -1;
                propertyChangedCounter.Target = result;
            }

            return(result);
        }
Пример #11
0
        public async Task ProcessMessages_EmptyMessage_LastMessageIdIsUpdated()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ScrumMasterName);

            var message = new Message
            {
                Id   = 4,
                Type = MessageType.Empty
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(4, target.LastMessageId);
        }
Пример #12
0
        public async Task ProcessMessages_2xMemberJoinedWithMember_3Members()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.State = TeamState.EstimationInProgress;
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(CreateTeamResult(scrumTeam), PlanningPokerData.ScrumMasterName);

            var message1 = new MemberMessage
            {
                Id     = 1,
                Type   = MessageType.MemberJoined,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "XYZ"
                }
            };
            var message2 = new MemberMessage
            {
                Id     = 2,
                Type   = MessageType.MemberJoined,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "New member"
                }
            };

            target.ProcessMessages(new Message[] { message1, message2 });

            Assert.AreEqual(2, propertyChangedCounter.Count);
            Assert.AreEqual(2, target.LastMessageId);
            var expectedMembers = new string[] { "New member", PlanningPokerData.MemberName, "XYZ" };

            CollectionAssert.AreEqual(expectedMembers, target.Members.Select(m => m.Name).ToList());
            expectedMembers = new string[] { PlanningPokerData.ObserverName };
            CollectionAssert.AreEqual(expectedMembers, target.Observers.Select(m => m.Name).ToList());
            PlanningPokerControllerTest.AssertNoMemberHasEstimated(target);
        }
Пример #13
0
        public async Task ProcessMessages_EstimationStartedAndStateIsInitialize_StateIsEstimationInProgress()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();
            var target    = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.MemberName);

            var message = new Message
            {
                Id   = 1,
                Type = MessageType.EstimationStarted
            };

            ProcessMessage(target, message);

            Assert.AreEqual(1, propertyChangedCounter.Count);
            Assert.AreEqual(1, target.LastMessageId);
            Assert.AreEqual(TeamState.EstimationInProgress, target.ScrumTeam.State);
            Assert.IsTrue(target.CanSelectEstimation);
            Assert.IsFalse(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);
        }
Пример #14
0
        public async Task ProcessMessages_EstimationEndedAndSameEstimationCountWithNull_6Estimations()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Developer 1"
            });
            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Developer 2"
            });
            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Tester 1"
            });
            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Tester 2"
            });
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.MemberName);

            var message = new EstimationResultMessage
            {
                Id               = 10,
                Type             = MessageType.EstimationEnded,
                EstimationResult = new List <EstimationResultItem>
                {
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.ScrumMasterType, Name = PlanningPokerData.ScrumMasterName
                        },
                        Estimation = new Estimation {
                            Value = double.PositiveInfinity
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Developer 2"
                        },
                        Estimation = new Estimation {
                            Value = null
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Tester 1"
                        },
                        Estimation = new Estimation {
                            Value = null
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = PlanningPokerData.MemberName
                        },
                        Estimation = new Estimation {
                            Value = double.PositiveInfinity
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Developer 1"
                        },
                        Estimation = new Estimation {
                            Value = 5
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Tester 2"
                        },
                        Estimation = new Estimation {
                            Value = 5
                        }
                    }
                }
            };

            StartEstimation(target);
            ProcessMessage(target, message);

            Assert.AreEqual(2, propertyChangedCounter.Count);
            Assert.AreEqual(10, target.LastMessageId);
            Assert.AreEqual(TeamState.EstimationFinished, target.ScrumTeam.State);
            Assert.IsFalse(target.CanSelectEstimation);
            Assert.IsFalse(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);

            var estimations = target.Estimations.ToList();

            Assert.AreEqual(6, estimations.Count);

            var estimation = estimations[0];

            Assert.AreEqual("Developer 1", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(5.0, estimation.Estimation);

            estimation = estimations[1];
            Assert.AreEqual("Tester 2", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(5.0, estimation.Estimation);

            estimation = estimations[2];
            Assert.AreEqual(PlanningPokerData.MemberName, estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(double.PositiveInfinity, estimation.Estimation);

            estimation = estimations[3];
            Assert.AreEqual(PlanningPokerData.ScrumMasterName, estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(double.PositiveInfinity, estimation.Estimation);

            estimation = estimations[4];
            Assert.AreEqual("Developer 2", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.IsNull(estimation.Estimation);

            estimation = estimations[5];
            Assert.AreEqual("Tester 1", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.IsNull(estimation.Estimation);
        }
Пример #15
0
        public async Task ProcessMessages_EstimationEnded_5Estimations()
        {
            var propertyChangedCounter = new PropertyChangedCounter();
            var scrumTeam = PlanningPokerData.GetScrumTeam();

            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Developer 1"
            });
            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Tester"
            });
            scrumTeam.Members.Add(new TeamMember {
                Type = PlanningPokerData.MemberType, Name = "Developer 2"
            });
            var target = CreateController(propertyChangedCounter);
            await target.InitializeTeam(scrumTeam, PlanningPokerData.ScrumMasterName);

            var message1 = new MemberMessage
            {
                Id     = 5,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "Developer 1"
                }
            };
            var message2 = new MemberMessage
            {
                Id     = 6,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = PlanningPokerData.MemberName
                }
            };
            var message3 = new MemberMessage
            {
                Id     = 7,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.ScrumMasterType,
                    Name = PlanningPokerData.ScrumMasterName
                }
            };
            var message4 = new MemberMessage
            {
                Id     = 8,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "Tester"
                }
            };
            var message5 = new MemberMessage
            {
                Id     = 9,
                Type   = MessageType.MemberEstimated,
                Member = new TeamMember
                {
                    Type = PlanningPokerData.MemberType,
                    Name = "Developer 2"
                }
            };

            var message = new EstimationResultMessage
            {
                Id               = 10,
                Type             = MessageType.EstimationEnded,
                EstimationResult = new List <EstimationResultItem>
                {
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Developer 1"
                        },
                        Estimation = new Estimation {
                            Value = 8
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Tester"
                        },
                        Estimation = new Estimation {
                            Value = 8
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.ScrumMasterType, Name = PlanningPokerData.ScrumMasterName
                        },
                        Estimation = new Estimation {
                            Value = 3
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = PlanningPokerData.MemberName
                        },
                        Estimation = new Estimation {
                            Value = 8
                        }
                    },
                    new EstimationResultItem
                    {
                        Member = new TeamMember {
                            Type = PlanningPokerData.MemberType, Name = "Developer 2"
                        },
                        Estimation = new Estimation {
                            Value = 2
                        }
                    }
                }
            };

            StartEstimation(target);
            ProcessMessage(target, message1);
            target.ProcessMessages(new Message[] { message2, message3, message4 });
            target.ProcessMessages(new Message[] { message5, message });

            Assert.AreEqual(7, propertyChangedCounter.Count);
            Assert.AreEqual(10, target.LastMessageId);
            Assert.AreEqual(TeamState.EstimationFinished, target.ScrumTeam.State);
            Assert.IsFalse(target.CanSelectEstimation);
            Assert.IsTrue(target.CanStartEstimation);
            Assert.IsFalse(target.CanCancelEstimation);

            var estimations = target.Estimations.ToList();

            Assert.AreEqual(5, estimations.Count);

            var estimation = estimations[0];

            Assert.AreEqual("Developer 1", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(8.0, estimation.Estimation);

            estimation = estimations[1];
            Assert.AreEqual(PlanningPokerData.MemberName, estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(8.0, estimation.Estimation);

            estimation = estimations[2];
            Assert.AreEqual("Tester", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(8.0, estimation.Estimation);

            estimation = estimations[3];
            Assert.AreEqual("Developer 2", estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(2.0, estimation.Estimation);

            estimation = estimations[4];
            Assert.AreEqual(PlanningPokerData.ScrumMasterName, estimation.MemberName);
            Assert.IsTrue(estimation.HasEstimation);
            Assert.AreEqual(3.0, estimation.Estimation);
        }