public void ThenCheckValidCharacters()
        {
            var validChars = GetValidCharacters();
            var request    = new StubRequest {
                TestString = validChars
            };
            var sut = new TestMatchesAllowedHtmlFreeTextCharactersValidator();

            var result = sut.Validate(request);

            result.IsValid.Should().BeTrue();
        }
        public void ThenCheckBlacklistHtmlElements(string text)
        {
            var request = new StubRequest {
                TestString = text
            };
            var sut = new TestMatchesAllowedHtmlFreeTextCharactersValidator();

            var result = sut.Validate(request);

            result.IsValid.Should().BeFalse();
            result.Errors.First().ErrorCode.Should().Be(ErrorCode);
        }
        public void ThenCheckInvalidCharacters()
        {
            var validChars = GetValidCharacters().ToCharArray().Select(c => (int)c).ToArray();

            //65450 is just an arbitary number that is greater than 65447. Any characters greater than 65447 will fail.
            var allChars = Enumerable.Range(0, 65450).ToArray();

            var invalidChars = allChars.Except(validChars).Select(i => (char)i).ToArray();

            var sut = new TestMatchesAllowedHtmlFreeTextCharactersValidator();

            foreach (var invalidChar in invalidChars)
            {
                var request = new StubRequest {
                    TestString = invalidChar.ToString()
                };
                var result = sut.Validate(request);

                result.IsValid.Should().BeFalse();
                result.Errors.Single().ErrorMessage.Should().Be("'Test String' can't contain invalid characters");
            }
        }