59 lines
No EOL
2.2 KiB
C#
59 lines
No EOL
2.2 KiB
C#
using System;
|
||
using BirdsiteLive.Common.Settings;
|
||
using BirdsiteLive.Domain.Tools;
|
||
using BirdsiteLive.Twitter.Models;
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||
|
||
namespace BirdsiteLive.Domain.Tests.Tools
|
||
{
|
||
[TestClass]
|
||
public class StatusExtractorTests
|
||
{
|
||
private readonly InstanceSettings _settings;
|
||
|
||
#region Ctor
|
||
public StatusExtractorTests()
|
||
{
|
||
_settings = new InstanceSettings
|
||
{
|
||
Domain = "domain.name"
|
||
};
|
||
}
|
||
#endregion
|
||
|
||
[TestMethod]
|
||
public void Extract_SingleTag_Test()
|
||
{
|
||
#region Stubs
|
||
var message = $"Bla!{Environment.NewLine}#mytag";
|
||
#endregion
|
||
|
||
var service = new StatusExtractor(_settings);
|
||
var result = service.ExtractTags(message);
|
||
|
||
#region Validations
|
||
Assert.IsTrue(result.content.Contains("Bla!"));
|
||
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag"" class=""mention hashtag"" rel=""tag"">#<span>mytag</span></a>"));
|
||
#endregion
|
||
}
|
||
|
||
[TestMethod]
|
||
public void Extract_MultiTags_Test()
|
||
{
|
||
#region Stubs
|
||
var message = $"Bla!{Environment.NewLine}#mytag #mytag2 #mytag3{Environment.NewLine}Test #bal Test";
|
||
#endregion
|
||
|
||
var service = new StatusExtractor(_settings);
|
||
var result = service.ExtractTags(message);
|
||
|
||
#region Validations
|
||
Assert.IsTrue(result.content.Contains("Bla!"));
|
||
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag"" class=""mention hashtag"" rel=""tag"">#<span>mytag</span></a>"));
|
||
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag2"" class=""mention hashtag"" rel=""tag"">#<span>mytag2</span></a>"));
|
||
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag3"" class=""mention hashtag"" rel=""tag"">#<span>mytag3</span></a>"));
|
||
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/bal"" class=""mention hashtag"" rel=""tag"">#<span>bal</span></a>"));
|
||
#endregion
|
||
}
|
||
}
|
||
} |