コード例 #1
0
        public void Load_with_absolute_path_uses_correct_method()
        {
            // Arrange
              var thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
              var thisAssemblyFile = new FileInfo(thisAssemblyPath);
              var thisAssemblyDir = thisAssemblyFile.GetParentDirectory();
              var absPath = Path.Combine(thisAssemblyDir.FullName, "Foo.dll");

              // Act
              _sut.Object.Load(absPath);

              // Assert
              _sut.Verify(x => x.LoadAbsolute(It.IsAny<string>()), Times.Once());
              _sut.Verify(x => x.LoadRelative(It.IsAny<string>()), Times.Never());
        }
コード例 #2
0
ファイル: RenderingJob.cs プロジェクト: csf-dev/ZPT-Sharp
        private Stream GetOutputStream(FileInfo outputFile)
        {
            var parentDir = outputFile.GetParentDirectory();
              if(!parentDir.Exists)
              {
            parentDir.CreateRecursively();
              }

              return outputFile.Open(FileMode.Create);
        }
コード例 #3
0
        protected bool PerformTestRun(FileInfo sourceDocument,
                                  FileInfo expectedResultDocument)
        {
            bool output = false;
              IZptDocument document = null;
              string expectedRendering, actualRendering = null;
              bool exceptionCaught = false;

              try
              {
            document = _documentFactory.CreateDocument(sourceDocument);
              }
              catch(Exception ex)
              {
            _logger.ErrorFormat("Exception caught whilst loading the source document:{0}{1}{2}",
                            expectedResultDocument.Name,
                            Environment.NewLine,
                            ex);
            exceptionCaught = true;
              }

              if(!exceptionCaught)
              {
            using(var stream = expectedResultDocument.OpenRead())
            using(var reader = new StreamReader(stream))
            {
              expectedRendering = reader.ReadToEnd();
            }

            try
            {
              var rootDir = sourceDocument.GetParentDirectory().GetParentDirectory();
              var options = GetRenderingSettings(this.CreateTestEnvironment(rootDir));

              actualRendering = this.Render(document, options);
              output = (actualRendering == expectedRendering);
            }
            catch(Exception ex)
            {
              _logger.ErrorFormat("Exception caught whilst processing output file:{0}{1}{2}",
                              expectedResultDocument.Name,
                              Environment.NewLine,
                              ex);
              output = false;
              exceptionCaught = true;
            }
              }

              if(!output && !exceptionCaught)
              {
            _logger.ErrorFormat("Unexpected rendering whilst processing expected output:{0}{1}{2}",
                            expectedResultDocument.Name,
                            Environment.NewLine,
                            actualRendering);
              }

              return output;
        }
コード例 #4
0
 public void TestGetParent()
 {
   DirectoryInfo currentDir = new DirectoryInfo(System.Environment.CurrentDirectory);
   FileInfo file = new FileInfo(currentDir.FullName + Path.DirectorySeparatorChar + "testFile.txt");
   
   Assert.AreEqual(currentDir,
                   file.GetParentDirectory(),
                   "File");
   Assert.AreEqual(currentDir.Parent,
                   currentDir.GetParentDirectory(),
                   "Directory");
   Assert.IsNull(currentDir.Root.GetParentDirectory(), "Filesystem root");
 }