public void Not_Convert_When_Invalid_Parameters() { var sut = new RtfSpecialCharactersConverter(); object result = null; Assert.DoesNotThrow(() => result = sut.Convert(null, typeof(string), null, CultureInfo.CurrentCulture)); result.Should().Be(Binding.DoNothing); Assert.DoesNotThrow(() => result = sut.Convert(new object(), typeof(string), null, CultureInfo.CurrentCulture)); result.Should().Be(Binding.DoNothing); Assert.DoesNotThrow(() => result = sut.Convert("some string", null, null, CultureInfo.CurrentCulture)); result.Should().Be(Binding.DoNothing); Assert.DoesNotThrow(() => result = sut.Convert("some string", typeof(object), null, CultureInfo.CurrentCulture)); result.Should().Be(Binding.DoNothing); }
public void Convert_When_Special_Character() { var sut = new RtfSpecialCharactersConverter(); const string input = "some weird input string: äöü ß"; const string expected = "some weird input string: \\'e4\\'f6\\'fc \\'df"; var result = sut.Convert(input, typeof(string), null, CultureInfo.CurrentCulture) as string; result.Should().NotBeNull(); result.Should().Contain(expected); }
public void Convert_Back_And_Forth() { var sut = new RtfSpecialCharactersConverter(); // ReSharper disable once StringLiteralTypo const string expected = "äöüß一個mộtля"; var converted = sut.Convert(expected, typeof(string), null, CultureInfo.CurrentCulture); var result = sut.ConvertBack(converted, typeof(string), null, CultureInfo.CurrentCulture); result.Should().NotBeNull(); result.Should().Be(expected); }