public void GetScrumTeam_ExpiredTeamInRepository_ThrowsException()
        {
            // Arrange
            var timeProvider  = new DateTimeProviderMock();
            var configuration = new Mock <IPlanningPokerConfiguration>(MockBehavior.Strict);

            configuration.SetupGet(c => c.ClientInactivityTimeout).Returns(TimeSpan.FromMinutes(15));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 0, 0, DateTimeKind.Utc));
            var team   = new ScrumTeam("team", timeProvider);
            var master = team.SetScrumMaster("master");

            master.UpdateActivity();

            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns(team);
            repository.Setup(r => r.DeleteScrumTeam("team"));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 16, 0, DateTimeKind.Utc));
            var target = new PlanningPokerController(timeProvider, configuration.Object, repository.Object);

            // Act
            target.GetScrumTeam("team");
        }
        public void GetScrumTeam_TeamAlreadyLoaded_NotLoadingAgain()
        {
            // Arrange
            var timeProvider  = new DateTimeProviderMock();
            var configuration = new Mock <IPlanningPokerConfiguration>(MockBehavior.Strict);

            configuration.SetupGet(c => c.ClientInactivityTimeout).Returns(TimeSpan.FromMinutes(15));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 0, 0, DateTimeKind.Utc));
            var team   = new ScrumTeam("team");
            var master = team.SetScrumMaster("master");

            master.UpdateActivity();

            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns(team);

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 14, 0, DateTimeKind.Utc));
            var target = new PlanningPokerController(timeProvider, configuration.Object, repository.Object);

            // Act
            using (target.GetScrumTeam("team"))
            {
            }

            using (var teamLock = target.GetScrumTeam("team"))
            {
                // Verify
                Assert.AreEqual <ScrumTeam>(team, teamLock.Team);
                repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
                repository.Verify(r => r.DeleteScrumTeam("team"), Times.Never());
            }
        }
        public void ScrumTeamNames_2TeamsInRepositoryAnd2TeamCreated_Returns2Teams()
        {
            // Arrange
            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.SetupGet(r => r.ScrumTeamNames).Returns(new string[] { "team1", "team2" });
            repository.Setup(r => r.LoadScrumTeam("team1")).Returns((ScrumTeam)null);
            repository.Setup(r => r.LoadScrumTeam("team3")).Returns((ScrumTeam)null);
            var target = new PlanningPokerController(null, null, repository.Object);

            using (target.CreateScrumTeam("team1", "master"))
            {
            }

            using (target.CreateScrumTeam("team3", "master"))
            {
            }

            // Act
            var result = target.ScrumTeamNames;

            // Verify
            repository.VerifyGet(r => r.ScrumTeamNames);
            Assert.IsNotNull(result);
            CollectionAssert.AreEquivalent(new string[] { "team1", "team2", "team3" }, result.ToList());
        }
Ejemplo n.º 4
0
        public void DisconnectInactiveObservers_InactiveObserver_ObserverIsDisconnected()
        {
            // Arrange
            var dateTimeProvider = new DateTimeProviderMock();

            dateTimeProvider.SetUtcNow(new DateTime(2012, 1, 1, 3, 2, 20));

            var       target = new PlanningPokerController(dateTimeProvider, null, null);
            ScrumTeam team;

            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                team = teamLock.Team;
                team.Join("observer", true);
            }

            dateTimeProvider.SetUtcNow(new DateTime(2012, 1, 1, 3, 2, 55));
            team.ScrumMaster.UpdateActivity();

            // Act
            target.DisconnectInactiveObservers(TimeSpan.FromSeconds(30.0));

            // Verify
            using (var teamLock = target.GetScrumTeam("team"))
            {
                Assert.AreEqual <int>(0, teamLock.Team.Observers.Count());
            }
        }
        public void CreateScrumTeam_TeamAlreadyLoaded_NotLoadingAgain()
        {
            // Arrange
            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns((ScrumTeam)null);
            var target = new PlanningPokerController(null, null, repository.Object);

            using (target.CreateScrumTeam("team", "master"))
            {
            }

            // Act
            try
            {
                target.CreateScrumTeam("team", "master");
            }
            catch (ArgumentException)
            {
                // expected exception when adding same team
            }

            // Verify
            repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
        }
        public void CreateScrumTeam_TeamInRepository_DoesNotDeleteOldTeam()
        {
            // Arrange
            var timeProvider  = new DateTimeProviderMock();
            var configuration = new Mock <IPlanningPokerConfiguration>(MockBehavior.Strict);

            configuration.SetupGet(c => c.ClientInactivityTimeout).Returns(TimeSpan.FromMinutes(15));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 0, 0, DateTimeKind.Utc));
            var team   = new ScrumTeam("team");
            var master = team.SetScrumMaster("master");

            master.UpdateActivity();

            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns(team);

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 14, 0, DateTimeKind.Utc));
            var target = new PlanningPokerController(timeProvider, configuration.Object, repository.Object);

            // Act
            try
            {
                target.CreateScrumTeam("team", "master");
            }
            catch (ArgumentException)
            {
                // expected exception when adding same team
            }

            // Verify
            repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
            repository.Verify(r => r.DeleteScrumTeam("team"), Times.Never());
        }
Ejemplo n.º 7
0
        public void CreateScrumTeam_ScrumMasterNameIsEmpty_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.CreateScrumTeam("test team", string.Empty);
        }
Ejemplo n.º 8
0
        public void GetScrumTeam_TeamNameIsEmpty_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.GetScrumTeam(string.Empty);
        }
Ejemplo n.º 9
0
        public void GetScrumTeam_TeamNameNotExists_ArgumentException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.GetScrumTeam("team");
        }
Ejemplo n.º 10
0
        public void PlanningPokerController_Create_DefaultDateTimeProvider()
        {
            // Act
            var result = new PlanningPokerController();

            // Verify
            Assert.AreEqual <DateTimeProvider>(DateTimeProvider.Default, result.DateTimeProvider);
        }
Ejemplo n.º 11
0
        public void GetMessagesAsync_ObserverIsNull_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.GetMessagesAsync(null, (f, o) => { });
        }
Ejemplo n.º 12
0
        public void CreateScrumTeam_TeamNameIsEmpty_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.CreateScrumTeam(string.Empty, "master");
        }
Ejemplo n.º 13
0
        public void AttachScrumTeam_Null_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            target.AttachScrumTeam(null);
        }
Ejemplo n.º 14
0
        public void GetScrumTeam_TeamCreatedWhileLoading_DoesNotCreateNewTeam()
        {
            // Arrange
            var timeProvider  = new DateTimeProviderMock();
            var configuration = new Mock <IPlanningPokerConfiguration>(MockBehavior.Strict);

            configuration.SetupGet(c => c.ClientInactivityTimeout).Returns(TimeSpan.FromMinutes(15));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 0, 0, DateTimeKind.Utc));
            var team   = new ScrumTeam("team");
            var master = team.SetScrumMaster("master");

            master.UpdateActivity();

            bool firstLoad   = true;
            bool firstReturn = true;
            PlanningPokerController target = null;
            ScrumTeam createdTeam          = null;

            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team"))
            .Callback <string>(n =>
            {
                if (firstLoad)
                {
                    firstLoad = false;
                    using (var teamLock = target.CreateScrumTeam("team", "master"))
                    {
                        createdTeam = teamLock.Team;
                    }
                }
            }).Returns <string>(n =>
            {
                if (firstReturn)
                {
                    firstReturn = false;
                    return(null);
                }
                else
                {
                    return(team);
                }
            });

            target = CreatePlanningPokerController(timeProvider, configuration.Object, repository.Object);

            // Act
            using (var teamLock = target.GetScrumTeam("team"))
            {
                // Verify
                Assert.AreNotEqual <ScrumTeam>(team, createdTeam);
                Assert.AreNotEqual <ScrumTeam>(team, teamLock.Team);
                Assert.AreEqual <ScrumTeam>(createdTeam, teamLock.Team);
                repository.Verify(r => r.LoadScrumTeam("team"), Times.Exactly(2));
                repository.Verify(r => r.DeleteScrumTeam("team"), Times.Never());
            }
        }
Ejemplo n.º 15
0
        public void CreateScrumTeam_TeamCreatedWhileLoading_DoesNotCreateNewTeam()
        {
            // Arrange
            var timeProvider  = new DateTimeProviderMock();
            var configuration = new Mock <IPlanningPokerConfiguration>(MockBehavior.Strict);

            configuration.SetupGet(c => c.ClientInactivityTimeout).Returns(TimeSpan.FromMinutes(15));

            timeProvider.SetUtcNow(new DateTime(2015, 1, 1, 10, 0, 0, DateTimeKind.Utc));
            var team   = new ScrumTeam("team");
            var master = team.SetScrumMaster("master");

            master.UpdateActivity();

            bool firstLoad   = true;
            bool firstReturn = true;
            PlanningPokerController target = null;

            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team"))
            .Callback <string>(n =>
            {
                if (firstLoad)
                {
                    firstLoad = false;
                    try
                    {
                        using (var teamLock = target.CreateScrumTeam("team", "master", Deck.Standard))
                        {
                            Assert.AreNotEqual <ScrumTeam>(team, teamLock.Team);
                        }
                    }
                    catch (ArgumentException)
                    {
                        // if ArgumentException is here, test should fail
                    }
                }
            }).Returns <string>(n =>
            {
                if (firstReturn)
                {
                    firstReturn = false;
                    return(null);
                }
                else
                {
                    return(team);
                }
            });

            target = CreatePlanningPokerController(timeProvider, configuration.Object, repository.Object);

            // Act
            Assert.ThrowsException <ArgumentException>(() => target.CreateScrumTeam("team", "master", Deck.Standard));
        }
Ejemplo n.º 16
0
        private static void StartEstimation(PlanningPokerController controller)
        {
            var message = new Message
            {
                Id   = 1,
                Type = MessageType.EstimationStarted
            };

            ProcessMessage(controller, message);
        }
Ejemplo n.º 17
0
        public void PlanningPokerController_Configuration_ConfigurationIsSet()
        {
            // Arrange
            var configuration = new Duracellko.PlanningPoker.Configuration.PlanningPokerConfigurationElement();

            // Act
            var result = new PlanningPokerController(null, configuration, null);

            // Verify
            Assert.AreEqual(configuration, result.Configuration);
        }
Ejemplo n.º 18
0
        public void PlanningPokerController_SpecificDateTimeProvider_DateTimeProviderIsSet()
        {
            // Arrange
            var dateTimeProvider = new DateTimeProviderMock();

            // Act
            var result = new PlanningPokerController(dateTimeProvider, null, null);

            // Verify
            Assert.AreEqual <DateTimeProvider>(dateTimeProvider, result.DateTimeProvider);
        }
Ejemplo n.º 19
0
        public void GetMessagesAsync_CallbackIsNull_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                // Act
                target.GetMessagesAsync(teamLock.Team.ScrumMaster, null);
            }
        }
Ejemplo n.º 20
0
        public void CreateScrumTeam_TeamNameAlreadyExists_ArgumentException()
        {
            // Arrange
            var target = new PlanningPokerController();
            var team   = target.CreateScrumTeam("team", "master");

            team.Dispose();

            // Act
            target.CreateScrumTeam("team", "master2");
        }
        public void GetScrumTeam_TeamNotInRepository_ReturnsTeamFromRepository()
        {
            // Arrange
            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns((ScrumTeam)null);

            var target = new PlanningPokerController(null, null, repository.Object);

            // Act
            target.GetScrumTeam("team");
        }
Ejemplo n.º 22
0
        public void AttachScrumTeam_ScrumTeam_TeamIsInCollection()
        {
            // Arrange
            var team   = new ScrumTeam("test team");
            var target = new PlanningPokerController();

            // Act
            target.AttachScrumTeam(team);

            // Verify
            Assert.IsNotNull(target.GetScrumTeam(team.Name));
        }
Ejemplo n.º 23
0
        public void AttachScrumTeam_ScrumTeam_ReturnsSameTeam()
        {
            // Arrange
            var team   = new ScrumTeam("test team");
            var target = new PlanningPokerController();

            // Act
            var result = target.AttachScrumTeam(team);

            // Verify
            Assert.AreEqual <ScrumTeam>(team, result.Team);
        }
        public void GetScrumTeam_EmptyTeamInRepository_ThrowsException()
        {
            // 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 = new PlanningPokerController(null, null, repository.Object);

            // Act
            target.GetScrumTeam("team");
        }
Ejemplo n.º 25
0
        public void CreateScrumTeam_ScrumMasterName_CreatedTeamWithSpecifiedScrumMaster()
        {
            // Arrange
            var target = new PlanningPokerController();

            // Act
            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                // Verify
                Assert.IsNotNull(teamLock.Team.ScrumMaster);
                Assert.AreEqual <string>("master", teamLock.Team.ScrumMaster.Name);
            }
        }
Ejemplo n.º 26
0
        public void CreateScrumTeam_SpecificDateTimeProvider_CreatedTeamWithDateTimeProvider()
        {
            // Arrange
            var dateTimeProvider = new DateTimeProviderMock();
            var target           = new PlanningPokerController(dateTimeProvider, null, null);

            // Act
            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                // Verify
                Assert.AreEqual <DateTimeProvider>(dateTimeProvider, teamLock.Team.DateTimeProvider);
            }
        }
Ejemplo n.º 27
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);
        }
        public void CreateScrumTeam_TeamNotInRepository_TriedToLoadFromRepository()
        {
            // Arrange
            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.Setup(r => r.LoadScrumTeam("team")).Returns((ScrumTeam)null);
            var target = new PlanningPokerController(null, null, repository.Object);

            // Act
            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                // Verify
                Assert.IsNotNull(teamLock);
                repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
            }
        }
        public void ScrumTeamNames_AllEmpty_ReturnsZeroTeams()
        {
            // Arrange
            var repository = new Mock <IScrumTeamRepository>(MockBehavior.Strict);

            repository.SetupGet(r => r.ScrumTeamNames).Returns(Enumerable.Empty <string>());
            var target = new PlanningPokerController(null, null, repository.Object);

            // Act
            var result = target.ScrumTeamNames;

            // Verify
            repository.VerifyGet(r => r.ScrumTeamNames);
            Assert.IsNotNull(result);
            CollectionAssert.AreEquivalent(new string[0], result.ToList());
        }
Ejemplo n.º 30
0
        public void GetScrumTeam_AfterDisconnectingAllMembers_ArgumentException()
        {
            // Arrange
            var       target = new PlanningPokerController();
            ScrumTeam team;

            using (var teamLock = target.CreateScrumTeam("team", "master"))
            {
                team = teamLock.Team;
            }

            team.Disconnect("master");

            // Act
            target.GetScrumTeam("team");
        }