public FileTemplateServices(PXHotelEntities entities) { _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>(); _pageTemplateServices = HostContainer.GetInstance <IPageTemplateServices>(); _fileTemplateRepository = new FileTemplateRepository(entities); _pageRepository = new PageRepository(entities); }
public FileTemplateServices(PXHotelEntities entities) { _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>(); _pageTemplateServices = HostContainer.GetInstance<IPageTemplateServices>(); _fileTemplateRepository = new FileTemplateRepository(entities); _pageRepository = new PageRepository(entities); }
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); }); }
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); }
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); }
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>()); }
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>()); }
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()); }
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()); }
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")); }