コード例 #1
0
            void CallFileCheck()
            {
                if (!isActive)
                {
                    return;
                }

                if (timer == null)
                {
                    WeakReference weakReference = new WeakReference(this);
                    timer = new Timer(new TimerCallback((o) =>
                    {
                        FileChecker fc = (FileChecker)weakReference.Target;
                        if (fc != null)
                        {
                            fc.CheckFile();
                            fc.CallFileCheck();
                        }
                    }), null, checkIntervall, Timeout.InfiniteTimeSpan);
                }
                else
                {
                    timer.Change(checkIntervall, Timeout.InfiniteTimeSpan);
                }
            }
コード例 #2
0
        public void TestMethod9()
        {
            StubExtensionManager stubManger = new StubExtensionManager();
            FileChecker          fc         = new FileChecker(stubManger);

            bool ret = fc.CheckFile("myfile");

            Assert.AreEqual(true, ret);
        }
コード例 #3
0
        public void TestMethod1()
        {
            //Act
            StubExtensionManager stub    = new StubExtensionManager();
            FileChecker          checker = new FileChecker(stub);

            //Action
            bool IsTrueFile = checker.CheckFile("myFile.whatever");

            //Assert
            Assert.AreEqual(true, IsTrueFile);
        }
コード例 #4
0
        public void When_CustomizationsDoNotHaveSitemap_Throws_SaysNoSiteMapFound()
        {
            Exception ex = Assert.ThrowsException <Exception>(() => FileChecker.CheckFile(@"TestFiles\TestSolution_1_0_0_0_managed_no_sitemap.zip"));

            Assert.AreEqual("No sitemap inside customizations.xml", ex.Message);
        }
コード例 #5
0
        public void When_ValidZipButNoCustomizations_Throws_SaysFileNotFound()
        {
            Exception ex = Assert.ThrowsException <Exception>(() => FileChecker.CheckFile(@"TestFiles\TestSolution_1_0_0_0_with_no_customizations.zip"));

            Assert.AreEqual("File customizations.xml not found in zip", ex.Message);
        }
コード例 #6
0
        public void When_NotAValidZip_Throws_SaysNotValidZip()
        {
            Exception ex = Assert.ThrowsException <Exception>(() => FileChecker.CheckFile(@"TestFiles\this_is_not_a_zip.zip"));

            Assert.AreEqual("Cannot read that as a ZipFile", ex.Message);
        }
コード例 #7
0
        public void When_FileDoesntExists_Throws_SaysFileNotFound()
        {
            Exception ex = Assert.ThrowsException <Exception>(() => FileChecker.CheckFile(@"TestFiles\does_not_exists.zip"));

            Assert.AreEqual("File not found", ex.Message);
        }
コード例 #8
0
 public void When_FileOK_DoesntThrowException()
 {
     FileChecker.CheckFile(@"TestFiles\TestSolution_1_0_0_0_managed.zip");
 }