Esempio n. 1
0
    private ITemplateReader GetReader(
        IEnumerable <string> listOfFiles,
        IDictionary <string, string> fileNameToContents)
    {
        Mock <IDirectoryEnumerator> directoryEnumeratorMock = DirectoryEnumeratorMockFactory.Get(listOfFiles);

        var fileReaderMock = FileReaderMockFactory.Get(fileNameToContents);

        var mockOptions = new Mock <CliOptions>();

        return(new TemplateReader(directoryEnumeratorMock.Object,
                                  fileReaderMock.Object,
                                  mockOptions.Object));
    }
    public void ShouldTryToReadFileAtRootOfTemplate()
    {
        // This test mostly just verifies that the reader is trying to read the correct file
        // And that it builds the correct path to the template;
        var fileCache = new Dictionary <string, string>
        {
            { Path.Combine("templates", "template", "site_template.html"), "fileContents" }
        };

        var readerMock = FileReaderMockFactory.Get(fileCache);

        var sut = new SiteTemplateLocalFileReader(readerMock.Object, new CliOptions {
            TemplateName = "template"
        });

        var result = sut.ReadTemplate();

        Assert.Equal("fileContents", result);
    }