public void TestConvertNullOrWhitespace() { // set up var converter = new SvgImageSourceTypeConverter(); // run + check var imageSource1 = converter.ConvertFromInvariantString(null); var imageSource2 = converter.ConvertFromInvariantString(string.Empty); // check Assert.IsNull(imageSource1, "null value must be converted to null ImageSource"); Assert.IsNull(imageSource2, "empty value must be converted to null ImageSource"); }
public void TestConvertFromSvgImageText() { // set up var converter = new SvgImageSourceTypeConverter(); // run string svgImageText = SvgTestImages.TestSvgImageText; var imageSource = converter.ConvertFromInvariantString(svgImageText); // check Assert.IsNotNull(imageSource, "non-null ImageSource must have been returned"); Assert.IsInstanceOf <UriImageSource>(imageSource, "must be an URI image source"); }
public void TestConvertFromResourceUri() { // set up var converter = new SvgImageSourceTypeConverter(); // run string resourceUri = $"resource://{SvgTestImages.ResourcePathColibriSvg}"; var imageSource = converter.ConvertFromInvariantString(resourceUri); // check Assert.IsNotNull(imageSource, "non-null ImageSource must have been returned"); Assert.IsInstanceOf <StreamImageSource>(imageSource, "must be a stream image source"); }
public void TestConvertFromFilename() { // set up var converter = new SvgImageSourceTypeConverter(); // run string filePath = "Assets/colibri.svg"; var imageSource = converter.ConvertFromInvariantString(filePath); // check Assert.IsNotNull(imageSource, "non-null ImageSource must have been returned"); Assert.IsInstanceOf <FileImageSource>(imageSource, "must be a file image source"); }
public void TestConvertFromInvalidDataUri() { // set up var converter = new SvgImageSourceTypeConverter(); // run + check string dataUri = SvgConstants.DataUriPlainPrefix + new string('-', 65536); Assert.Throws <FormatException>( () => converter.ConvertFromInvariantString(dataUri), "must throw format exception on invalid URI"); }
public void TestConvertFromDataUriBase64() { // set up var converter = new SvgImageSourceTypeConverter(); // run string dataUri = SvgConstants.DataUriBase64Prefix + SvgTestImages.EncodeBase64(SvgTestImages.TestSvgImageText); var imageSource = converter.ConvertFromInvariantString(dataUri); // check Assert.IsNotNull(imageSource, "non-null ImageSource must have been returned"); Assert.IsInstanceOf <UriImageSource>(imageSource, "must be an URI image source"); }