public void ContainsToken_TextContainsToken_ReturnsTrue(string input) { // arrange var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>()); // act var result = sut.ContainsToken(input); // assert Assert.That(result, Is.True); }
public void ContainsToken_TextDoesNotContainToken_ReturnsFalse() { // arrange var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>()); // act var result = sut.ContainsToken("lorem ipsum"); // assert Assert.That(result, Is.False); }
public void Replace_SettingsTokenNotPresent_ReturnsTextUnaltered(string input) { // arrange var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>()); var contextItem = ItemFactory.CreateItem().Object; // act var result = sut.Replace(input, contextItem); // assert Assert.That(result, Is.EqualTo(input)); }
public void Replace_TextIsEmptyOrNull_ReturnsEmptyString(string input) { // arrange var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>()); var contextItem = ItemFactory.CreateItem().Object; // act var result = sut.Replace(input, contextItem); // assert Assert.That(result, Is.Empty); }
public void Replace_TokenInsideOtherText_ReturnsWithTokenReplaced() { // arrange var entryTemplateId = ID.NewID; var settings = Mock.Of <IWeBlogSettings>(x => x.EntryTemplateIds == new[] { entryTemplateId }); var settingsResolver = Mock.Of <IBlogSettingsResolver>(x => x.Resolve(It.IsAny <BlogHomeItem>()) == new BlogSettings(settings)); var input = "query:.././/*[@@templateid='$weblogsetting(EntryTemplateID)']"; var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), settingsResolver); var contextItem = ItemFactory.CreateItem().Object; // act var result = sut.Replace(input, contextItem); // assert Assert.That(result, Is.EqualTo($"query:.././/*[@@templateid='{entryTemplateId}']")); }
public void Replace_InputContainsCategoryTemplateID_ReturnsCategoryTemplateID() { // arrange var categoryTemplateId = ID.NewID; var settings = Mock.Of <IWeBlogSettings>(x => x.CategoryTemplateIds == new[] { categoryTemplateId }); var settingsResolver = Mock.Of <IBlogSettingsResolver>(x => x.Resolve(It.IsAny <BlogHomeItem>()) == new BlogSettings(settings)); var input = "$weblogsetting(CATEGORYtemplateid)"; var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), settingsResolver); var contextItem = ItemFactory.CreateItem().Object; // act var result = sut.Replace(input, contextItem); // assert Assert.That(result, Is.EqualTo(categoryTemplateId.ToString())); }
public void Replace_InputContainsMultipleTokens_ReturnsWithTokensReplaced() { // arrange var categoryTemplateId = ID.NewID; var commentTemplateId = ID.NewID; var settings = Mock.Of <IWeBlogSettings>(x => x.CategoryTemplateIds == new[] { categoryTemplateId } && x.CommentTemplateIds == new[] { commentTemplateId } ); var settingsResolver = Mock.Of <IBlogSettingsResolver>(x => x.Resolve(It.IsAny <BlogHomeItem>()) == new BlogSettings(settings)); var input = "query:.././/*[@@templateid='$weblogsetting(CommentTemplateID)' OR @@templateid='$weblogsetting(categoryTemplateID)']"; var sut = new SettingsTokenReplacer(Mock.Of <IBlogManager>(), settingsResolver); var contextItem = ItemFactory.CreateItem().Object; // act var result = sut.Replace(input, contextItem); // assert Assert.That(result, Is.EqualTo($"query:.././/*[@@templateid='{commentTemplateId}' OR @@templateid='{categoryTemplateId}']")); }