mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-18 22:24:53 +02:00
.github
Configuration
Core
Data
Plugins
Properties
Resources
Updates
bld
lib
TweetLib.Communication
TweetLib.Core
TweetTest.System
TweetTest.Unit
Core
Data
TestCommandLineArgs.fs
TestInjectedHTML.fs
TestResult.fs
TestTwoKeyDictionary.fs
TweetTest.Unit.fsproj
packages.config
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
packages.config
* Switch to .NET Framework 4.7.2 & C# 8.0, update libraries * Add TweetLib.Core project targeting .NET Standard 2.0 * Enable reference nullability checks for TweetLib.Core * Move a bunch of utility classes into TweetLib.Core & refactor * Partially move TweetDuck plugin & update system to TweetLib.Core * Move some constants and CultureInfo setup to TweetLib.Core * Move some configuration classes to TweetLib.Core * Minor refactoring and warning suppression * Add App to TweetLib.Core * Add IAppErrorHandler w/ implementation * Continue moving config, plugin, and update classes to TweetLib.Core * Fix a few nullability checks * Update installers to check for .NET Framework 4.7.2
50 lines
2.5 KiB
Forth
50 lines
2.5 KiB
Forth
namespace TweetTest.Data.InjectedHTML
|
|
|
|
open Xunit
|
|
open TweetLib.Core.Data
|
|
|
|
|
|
module Inject =
|
|
let before = InjectedHTML.Position.Before
|
|
let after = InjectedHTML.Position.After
|
|
|
|
[<Fact>]
|
|
let ``injecting string before searched string works`` () =
|
|
Assert.Equal("<p>source[left]<br>code</p>", InjectedHTML(before, "<br>", "[left]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``injecting string after searched string works`` () =
|
|
Assert.Equal("<p>source<br>[right]code</p>", InjectedHTML(after, "<br>", "[right]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``injecting string at the beginning works`` () =
|
|
Assert.Equal("[start]<p>source<br>code</p>", InjectedHTML(before, "<p>", "[start]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``injecting string at the end works`` () =
|
|
Assert.Equal("<p>source<br>code</p>[end]", InjectedHTML(after, "</p>", "[end]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``injection only triggers for first occurrence of searched string`` () =
|
|
Assert.Equal("<p>source[left]<br>code</p><br>", InjectedHTML(before, "<br>", "[left]").InjectInto("<p>source<br>code</p><br>"))
|
|
Assert.Equal("<p>source<br>[right]code</p><br>", InjectedHTML(after, "<br>", "[right]").InjectInto("<p>source<br>code</p><br>"))
|
|
|
|
[<Fact>]
|
|
let ``empty searched string injects at the beginning`` () =
|
|
Assert.Equal("[start]<p>source<br>code</p>", InjectedHTML(before, "", "[start]").InjectInto("<p>source<br>code</p>"))
|
|
Assert.Equal("[start]<p>source<br>code</p>", InjectedHTML(after, "", "[start]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``injecting empty string does not modify source`` () =
|
|
Assert.Equal("<p>source<br>code</p>", InjectedHTML(before, "<br>", "").InjectInto("<p>source<br>code</p>"))
|
|
Assert.Equal("<p>source<br>code</p>", InjectedHTML(after, "<br>", "").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``failed match does not modify source`` () =
|
|
Assert.Equal("<p>source<br>code</p>", InjectedHTML(before, "<wrong>", "[left]").InjectInto("<p>source<br>code</p>"))
|
|
Assert.Equal("<p>source<br>code</p>", InjectedHTML(after, "<wrong>", "[right]").InjectInto("<p>source<br>code</p>"))
|
|
|
|
[<Fact>]
|
|
let ``invalid position does not modify source`` () =
|
|
Assert.Equal("<p>source<br>code</p>", InjectedHTML(enum<_>(1000), "<br>", "[somewhere]").InjectInto("<p>source<br>code</p>"))
|