예제 #1
0
    public void WriterShouldThrowErrorWhenFileAlreadyExists(string fileName)
    {
        var fileNames = new string[] { "testfile.html" };

        var mock = FileWriterMockFactory.Get();

        IHtmlFileWriter writerUnderTest = new FileSystemHtmlWriter(mock.Object);


        if (fileNames.Contains(fileName))
        {
            Assert.Throws <FileAlreadyExistsException>(() => writerUnderTest.Write(fileName, ""));
        }

        writerUnderTest.Write(fileName, "");

        mock.Verify(m => m.WriteFile(fileName, It.IsAny <string>()));
    }
예제 #2
0
    public void InputFileShouldBeWrittenAsHtml(string inputFileName, string ExpectedFileName)
    {
        var mock = FileWriterMockFactory.Get();

        IHtmlFileWriter writerUnderTest = new FileSystemHtmlWriter(mock.Object);

        writerUnderTest.Write(inputFileName, "");

        // Somehow validate that the input was called with an Html file
        mock.Verify(m => m.WriteFile(ExpectedFileName, It.IsAny <string>()));
    }