예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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());
        }
예제 #6
0
        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);
        }
예제 #7
0
        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();
        }