public void ConvertBackTest() { var converter = new StringToUriConverter(); Assert.AreEqual("harry.pott", converter.ConvertBack("harry.pott", null, null, null)); Assert.AreEqual("harry.pott", converter.ConvertBack(new Uri("harry.pott", UriKind.RelativeOrAbsolute), null, null, null)); }
public void ConvertTest() { var converter = new StringToUriConverter(); var uri = (Uri)converter.Convert("*****@*****.**", null, null, null) !; Assert.AreEqual("*****@*****.**", uri.OriginalString); uri = (Uri)converter.Convert("wrongAddress", null, null, null) !; Assert.AreEqual("wrongAddress", uri.OriginalString); uri = (Uri)converter.Convert(null, null, null, null) !; Assert.AreEqual("", uri.OriginalString); }
public void ShouldRegisterConverterImplicitly() { // Arrange const string InputString = "http://www.superdev.ch/"; var stringToUriConverter = new StringToUriConverter(); IConverterRegistry converterRegistry = new ConverterRegistry(); converterRegistry.RegisterConverter(stringToUriConverter); // Act var convertedObject = converterRegistry.Convert <string, Uri>(InputString); var outputString = converterRegistry.Convert <Uri, string>(convertedObject); // Assert convertedObject.Should().NotBeNull(); convertedObject.Should().BeOfType <Uri>(); convertedObject.As <Uri>().AbsoluteUri.Should().Be(InputString); outputString.Should().NotBeNullOrEmpty(); outputString.Should().Be(InputString); }
public void InitializeConverter() { _converter = new StringToUriConverter(); }