Exemplo n.º 1
0
        public void StartPopupWatcherTest_WithoutParameters_ThrowsException()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null);

            //Act + Assert
            Assert.Throws <ArgumentNullException>(() => PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, null));
            Assert.Throws <ArgumentNullException>(() => PopupWatcherLibrary.StartPopupWatcher(null, repoItemInfo));
        }
Exemplo n.º 2
0
        public void StopPopupWatcherTest_StopWithoutStart_ReportsFail()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            //Act
            PopupWatcherLibrary.StopPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Assert.AreEqual("The popup watcher you tried to remove does not exist.", logger.LastLogMessage);
        }
Exemplo n.º 3
0
        public void StartPopupWatcherTest_Single_Success()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null);

            //Act
            var watcher = PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Assert.IsNotNull(watcher);
            Assert.AreEqual("Popup watcher started.", logger.LastLogMessage);
        }
Exemplo n.º 4
0
        public void StopAllPopupWatcherTest_RemovesAllEntries_Success()
        {
            //Arrange
            var parentFolder  = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo1 = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());
            var repoItemInfo2 = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            PopupWatcherLibrary.StartPopupWatcher(repoItemInfo1, repoItemInfo1);
            PopupWatcherLibrary.StartPopupWatcher(repoItemInfo2, repoItemInfo2);

            //Act
            PopupWatcherLibrary.StopAllPopupWatchers();

            //Assert
            Assert.AreEqual("Popup watcher stopped.", logger.LastLogMessage);
            Assert.AreEqual(0, PopupWatcherLibrary.Watchers.Count);
        }
Exemplo n.º 5
0
        public void StopPopupWatcherTest_Single_Success()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/form", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());
            var logger       = new TestReportLogger();

            Report.AttachLogger(logger);
            var watcher = PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);

            //Act
            PopupWatcherLibrary.StopPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Report.DetachLogger(logger);
            Assert.IsNotNull(watcher);
            Assert.AreEqual("Popup watcher stopped.", logger.LastLogMessage);
        }
Exemplo n.º 6
0
        public void StartPopupWatcherTest_Twice_ThrowsException()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            //Act
            try
            {
                PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);
                PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);
                //Assert
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Popup watcher with given parameters already exists.", ex.Message);
            }
        }