Пример #1
0
        internal static void ExecuteTemplateRetrievalTest(this String templateFilename)
        {
            string templatePath = string.Empty.GetRandom();
            string expected     = System.IO.Path.Combine(templatePath, templateFilename);

            var mockFileService = new Mock <IFile>();

            mockFileService
            .Setup(f => f.ReadAllText(expected))
            .Returns(string.Empty.GetRandom())
            .Verifiable();

            var serviceProvider = new ServiceCollection()
                                  .AddFileService(mockFileService)
                                  .BuildServiceProvider();

            string connection = String.Format(_connectionFormat, templatePath);
            var    target     = new Yaml.ReadRepository(serviceProvider, connection);
            var    actual     = target.GetAllTemplates();

            mockFileService.Verify();
        }
Пример #2
0
        internal static void ExecuteTemplateContentTest(this String templateFilename, Enumerations.TemplateType templateType, String expected, String yamlFile)
        {
            string templatePath = string.Empty.GetRandom();
            string expectedPath = System.IO.Path.Combine(templatePath, templateFilename);

            var mockFileService = new Mock <IFile>();

            mockFileService
            .Setup(f => f.ReadAllText(It.IsAny <String>()))
            .Returns(string.Empty.GetRandom());
            mockFileService
            .Setup(f => f.ReadAllText(expectedPath))
            .Returns(yamlFile);

            var serviceProvider = new ServiceCollection()
                                  .AddFileService(mockFileService)
                                  .BuildServiceProvider();

            string connection = String.Format(_connectionFormat, templatePath);
            var    target     = new Yaml.ReadRepository(serviceProvider, connection);
            var    actual     = target.GetAllTemplates();

            Assert.Equal(expected, actual.Single(t => t.TemplateType == templateType).Content);
        }