Exemplo n.º 1
0
 public FileTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>();
     _pageTemplateServices      = HostContainer.GetInstance <IPageTemplateServices>();
     _fileTemplateRepository    = new FileTemplateRepository(entities);
     _pageRepository            = new PageRepository(entities);
 }
Exemplo n.º 2
0
 public FileTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageTemplateServices = HostContainer.GetInstance<IPageTemplateServices>();
     _fileTemplateRepository = new FileTemplateRepository(entities);
     _pageRepository = new PageRepository(entities);
 }
Exemplo n.º 3
0
        public void SaveTemplateWithSuccess(ITemplateRepository repository, ILogger logger, string templateFilePath, string templateContent, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a template file path"
            .x(() => templateFilePath = Path.GetTempFileName());

            "When saving the template"
            .x(async() => e = await Record.ExceptionAsync(async() => await repository.SaveTemplateAsync(templateFilePath, _templateContent)))
            .Teardown(() =>
            {
                if (File.Exists(templateFilePath))
                {
                    File.Delete(templateFilePath);
                }
            });

            "Then the save should succeed"
            .x(() => e.Should().BeNull());

            "And the saved template should contain the correct content"
            .x(() =>
            {
                using (var reader = new StreamReader(templateFilePath))
                {
                    templateContent = reader.ReadToEnd();
                }

                templateContent.Should().Be(_templateContent);
            });
        }
Exemplo n.º 4
0
 public PageTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageTemplateLogServices = HostContainer.GetInstance<IPageTemplateLogServices>();
     _settingServices = HostContainer.GetInstance<ISettingServices>();
     _templateServices = HostContainer.GetInstance<ITemplateServices>();
     _userServices = HostContainer.GetInstance<IUserServices>();
     _pageTemplateRepository = new PageTemplateRepository(entities);
     _fileTemplateRepository = new FileTemplateRepository(entities);
     _pageRepository = new PageRepository(entities);
     _pageTemplateLogRepository = new PageTemplateLogRepository(entities);
 }
Exemplo n.º 5
0
 public PageTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>();
     _pageTemplateLogServices   = HostContainer.GetInstance <IPageTemplateLogServices>();
     _settingServices           = HostContainer.GetInstance <ISettingServices>();
     _templateServices          = HostContainer.GetInstance <ITemplateServices>();
     _userServices              = HostContainer.GetInstance <IUserServices>();
     _pageTemplateRepository    = new PageTemplateRepository(entities);
     _fileTemplateRepository    = new FileTemplateRepository(entities);
     _pageRepository            = new PageRepository(entities);
     _pageTemplateLogRepository = new PageTemplateLogRepository(entities);
 }
Exemplo n.º 6
0
        public void SaveTemplateWithDirectoryNotFoundError(ITemplateRepository repository, ILogger logger, string templateFilePath, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a template file path"
            .x(() => templateFilePath = @"A:\badfile.json");

            "When saving the template"
            .x(async() => e = await Record.ExceptionAsync(async() => await repository.SaveTemplateAsync(templateFilePath, _templateContent)));

            "Then the save should fail"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <DirectoryNotFoundException>());
        }
Exemplo n.º 7
0
        public void SaveTemplateWithContentNullError(ITemplateRepository repository, ILogger logger, string templateFilePath, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a template file path"
            .x(() => templateFilePath = Path.GetTempFileName());

            "When saving the template with null content"
            .x(async() => e = await Record.ExceptionAsync(async() => await repository.SaveTemplateAsync(templateFilePath, null)));

            "Then the save should fail"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>());
        }
Exemplo n.º 8
0
        public void LoadTemplateWithFileNotFoundError(ITemplateRepository repository, ILogger logger, string templateContent, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "When loading the template for a file that doesn't exist"
            .x(async() => e = await Record.ExceptionAsync(async() => templateContent = await repository.LoadTemplateAsync("missingfile.json")));

            "Then the load should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <FileNotFoundException>());

            "And the template content should be null"
            .x(() => templateContent.Should().BeNull());
        }
Exemplo n.º 9
0
        public void LoadTemplateWithPathNullError(ITemplateRepository repository, ILogger logger, string templateContent, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "When loading the template for a file path that is null"
            .x(async() => e = await Record.ExceptionAsync(async() => templateContent = await repository.LoadTemplateAsync(null)));

            "Then the load should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>());

            "And the template content should be null"
            .x(() => templateContent.Should().BeNull());
        }
Exemplo n.º 10
0
        public void LoadTemplateWithSuccess(ITemplateRepository repository, ILogger logger, string templateContent, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileTemplateRepository(_mockLogger.Object));

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a template file that exists"
            .x(() => File.Exists(_tempTemplateFilePath).Should().BeTrue());

            "When loading the template"
            .x(async() => e = await Record.ExceptionAsync(async() => templateContent = await repository.LoadTemplateAsync(_tempTemplateFilePath)));

            "Then the load should succeed"
            .x(() => e.Should().BeNull());

            "And the template should contain the correct content"
            .x(() => templateContent.Should().StartWith("test template"));
        }