Ejemplo 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.");
        }
Ejemplo 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.");
        }