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());
            }
        }
Ejemplo n.º 2
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 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");
        }
Ejemplo n.º 4
0
        public void GetScrumTeam_TeamNameIsEmpty_ArgumentNullException()
        {
            // Arrange
            var target = new PlanningPokerController();

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

            // Act
            target.GetScrumTeam("team");
        }
Ejemplo n.º 6
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.º 7
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));
        }
        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");
        }
        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.º 10
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");
        }
Ejemplo n.º 11
0
        public void GetScrumTeam_TeamNameExists_ReturnsExistingTeam()
        {
            // Arrange
            var       target = new PlanningPokerController();
            ScrumTeam team;

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

            // Act
            using (var teamLock = target.GetScrumTeam("team"))
            {
                // Verify
                Assert.AreEqual <ScrumTeam>(team, teamLock.Team);
            }
        }
Ejemplo n.º 12
0
        public void DisconnectInactiveObservers_InactiveScrumMaster_TeamIsClosed()
        {
            // 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;
            }

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

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

            // Verify
            target.GetScrumTeam("team");
        }
        public void GetScrumTeam_DisconnectAfterwards_TeamIsRemovedFromRepository()
        {
            // 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);
            repository.Setup(r => r.DeleteScrumTeam("team"));
            repository.SetupGet(r => r.ScrumTeamNames).Returns(Enumerable.Empty <string>());

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

            // Act
            using (var teamLock = target.GetScrumTeam("team"))
            {
                teamLock.Team.Disconnect(master.Name);
                var result = target.ScrumTeamNames;

                // Verify
                Assert.AreEqual <ScrumTeam>(team, teamLock.Team);
                Assert.IsFalse(result.Any());
                repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
                repository.Verify(r => r.DeleteScrumTeam("team"), Times.Once());
            }
        }
        public void GetScrumTeam_EmptyTeamInRepository_DeletesOldTeam()
        {
            // 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
            try
            {
                target.GetScrumTeam("team");
            }
            catch (ArgumentException)
            {
                // expected exception
            }

            // Verify
            repository.Verify(r => r.LoadScrumTeam("team"), Times.Once());
            repository.Verify(r => r.DeleteScrumTeam("team"), Times.Once());
        }