Exemplo n.º 1
0
        public void FileChanged_Deleted_InvokesFileManager()
        {
            //Arrange
            var fileMonitor = new DummyFileMonitor();
            fileMonitor.WatchedFoldersAndPackages.Add(new MonitoredDirectory("~/ResourcePackages/My package/Mvc/Views/Layouts", true));
            var filePath = fileMonitor.AppPhysicalPath + "\\ResourcePackages\\My package\\Mvc\\Views\\Layouts\\test.cshtml";

            SystemManager.RunWithHttpContext(this.context, () =>
            {
                //Act
                fileMonitor.FileChangedTest(filePath, FileChangeType.Deleted);
            });

            //Assert
            Assert.AreEqual(1, fileMonitor.ResourceFileManager.DummyFileInfos.Count(), "FileDeleted method should be called.");
            Assert.AreEqual(FileChangeType.Deleted, fileMonitor.ResourceFileManager.DummyFileInfos.First().FileOperation, "FileDeleted method should be called.");
            Assert.AreEqual(filePath, fileMonitor.ResourceFileManager.DummyFileInfos.First().NewFilePath, "FileDeleted is called with wrong file name.");
        }
Exemplo n.º 2
0
        public void FileChanged_Created_InvokesFileManager()
        {
            // Arrange
            var fileMonitor = new DummyFileMonitor();
            fileMonitor.WatchedFoldersAndPackages.Add(new MonitoredDirectory("~/ResourcePackages/My package/Mvc/Views/Layouts", true));
            var filePath = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}\\ResourcePackages\\My package\\Mvc\\Views\\Layouts\\test.cshtml", fileMonitor.AppPhysicalPath);

            SystemManager.RunWithHttpContext(
                this.context,
                () =>
                    {
                        // Act
                        fileMonitor.FileChangedTest(filePath, FileChangeType.Created);
                    });

            // Assert
            Assert.AreEqual(1, fileMonitor.ResourceFileManager.DummyFileInfos.Count(), "FileAdded method should be called.");
            Assert.AreEqual(FileChangeType.Created, fileMonitor.ResourceFileManager.DummyFileInfos.First().FileOperation, "FileAdded method is not called.");
            Assert.AreEqual("test.cshtml", fileMonitor.ResourceFileManager.DummyFileInfos.First().NewFileName, "FileAdded is called with wrong file name.");
            Assert.AreEqual(filePath, fileMonitor.ResourceFileManager.DummyFileInfos.First().NewFilePath, "FileAdded is called with wrong file path.");
            Assert.AreEqual("My package", fileMonitor.ResourceFileManager.DummyFileInfos.First().PackageName, "FileAdded is called with wrong package name.");
        }
Exemplo n.º 3
0
        public void Start_NonExistingDirectories_AddedInQueuedFoldersAndPackages()
        {
            // Arrange
            var packageFolderPath = "~/" + PackageManager.PackagesFolder;
            var baseMvcPath = "~/Mvc/Views/Layouts";
            var fileMonitor = new DummyFileMonitor();

            var directoriesInfo = new List<MonitoredDirectory>();
            directoriesInfo.Add(new MonitoredDirectory(packageFolderPath, true));
            directoriesInfo.Add(new MonitoredDirectory(baseMvcPath, false));

            // Act
            fileMonitor.Start(directoriesInfo);

            // Assert
            Assert.AreEqual(2, fileMonitor.QueuedFoldersAndPackages.Count(), "Both folders should be added in QueuedFoldersAndPackages");
            Assert.AreEqual(packageFolderPath, fileMonitor.QueuedFoldersAndPackages[0].Path, "The package folder path is not added correctly.");
            Assert.IsTrue(fileMonitor.QueuedFoldersAndPackages[0].IsPackage, "The values in QueuedFoldersAndPackages are not correct.");
            Assert.AreEqual(baseMvcPath, fileMonitor.QueuedFoldersAndPackages[1].Path, "The base Mvc folder path is not added correctly.");
            Assert.IsFalse(fileMonitor.QueuedFoldersAndPackages[1].IsPackage, "The values in QueuedFoldersAndPackages are not correct.");
        }