public void ThrowWithTheProperSettingNameIfTitleIsNotSupplied() { string rootPath = $"c:\\{string.Empty.GetRandom()}\\"; var xml = new SettingsFileBuilder().UseRandomValues() .RemoveTitle().Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml.ToString()); SiteSettings actual; string expected = nameof(actual.Title); var target = (null as IContentRepository).Create(fileSystem.Object, rootPath); try { actual = target.GetSiteSettings(); } catch (SettingNotFoundException ex) { Assert.Equal(expected, ex.SettingName); } }
public void ReturnAnEmptyStringIfThemeIsNotSupplied() { var xml = new SettingsFileBuilder().UseRandomValues() .RemoveTheme().Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml.ToString()); var target = (null as IContentRepository).Create(fileSystem.Object, "c:\\"); var actual = target.GetSiteSettings(); Assert.Equal(string.Empty, actual.Theme); }
public void ReturnTheDefaultValueIfPostsPerFeedIsNotSupplied() { var xml = new SettingsFileBuilder().UseRandomValues() .RemovePostsPerFeed().Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml); var target = (null as IContentRepository).Create(fileSystem.Object, "c:\\"); var actual = target.GetSiteSettings(); Assert.Equal(_defaultPostsPerFeed, actual.PostsPerFeed); }
public void ReturnAnEmptyStringIfDescriptionIsNotSupplied() { var xml = new SettingsFileBuilder().UseRandomValues() .RemoveDescription().Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml); var target = (null as IContentRepository).Create(fileSystem.Object, "c:\\"); var actual = target.GetSiteSettings(); Assert.True(string.IsNullOrWhiteSpace(actual.Description)); }
public void ThrowSettingNotFoundExceptionIfTitleIsNotSupplied() { var xml = new SettingsFileBuilder() .UseRandomValues() .RemoveTitle() .Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml); var target = (null as IContentRepository).Create(fileSystem.Object, "c:\\"); Assert.Throws <SettingNotFoundException>(() => target.GetSiteSettings()); }
public void ReturnTheProperValueForTitle() { string expected = string.Empty.GetRandom(); string xml = new SettingsFileBuilder().UseRandomValues() .Title(expected).Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>())) .Returns(xml); var target = (null as IContentRepository).Create(fileSystem.Object, "c:\\"); var actual = target.GetSiteSettings(); Assert.Equal(expected, actual.Title); }
public void ReadsTheProperFileFromTheFileSystem() { string rootPath = $"c:\\{string.Empty.GetRandom()}\\"; string expectedPath = System.IO.Path.Combine(rootPath, _dataFolder, "settings.xml"); string xml = new SettingsFileBuilder().UseRandomValues().Build(); var fileSystem = new Mock <IFile>(); fileSystem.Setup(f => f.ReadAllText(It.Is <string>(p => p == expectedPath))) .Returns(xml).Verifiable(); var target = (null as IContentRepository).Create(fileSystem.Object, rootPath); var actual = target.GetSiteSettings(); fileSystem.VerifyAll(); }