Exemplo n.º 1
0
        public void ConvertFrom_ReadsFileAsIconWhenTypeIsBitmap()
        {
            var bitmapIconRefString = @"TestResources\Files\Error.ico;System.Drawing.Bitmap, System.Drawing.Common";
            var iconRefString       = @"TestResources\Files\Error.ico;System.Drawing.Icon, System.Drawing.Common";
            var converter           = new ResXFileRef.Converter();

            var iconResult   = (Icon)converter.ConvertFrom(null, null, iconRefString);
            var bitmapResult = (Bitmap)converter.ConvertFrom(null, null, bitmapIconRefString);

            Assert.Equal(iconResult.Size, bitmapResult.Size);
        }
Exemplo n.º 2
0
        public void ConvertFrom_ReturnNullWhenValueIsNotAString()
        {
            var value     = new object();
            var converter = new ResXFileRef.Converter();

            var result = converter.ConvertFrom(null, null, value);

            Assert.Null(result);
        }
Exemplo n.º 3
0
        public void ConvertFrom_ReadsFileAsMemoryStream()
        {
            var resxFileRefString = @"TestResources\Files\text.ansi.txt;System.IO.MemoryStream";
            var expected          = "Text";
            var converter         = new ResXFileRef.Converter();

            var result = (MemoryStream)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.Equal(expected, Encoding.Default.GetString(result.ToArray()));
        }
Exemplo n.º 4
0
        public void ConvertFrom_ReadsFileAsByteArray()
        {
            var resxFileRefString = @"TestResources\Files\text.ansi.txt;System.Byte[]";
            var expected          = "Text";
            var converter         = new ResXFileRef.Converter();

            var result = (byte[])converter.ConvertFrom(null, null, resxFileRefString);

            Assert.Equal(expected, Encoding.Default.GetString(result));
        }
Exemplo n.º 5
0
        public void ConvertFrom_ReadsFileAsStringUsingEncodingFromRefString()
        {
            var resxFileRefString = @"TestResources\Files\text.utf7.txt;System.String;utf-7";
            var expected          = "Привет";
            var converter         = new ResXFileRef.Converter();

            var result = (string)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.Equal(expected, result);
        }
Exemplo n.º 6
0
        public void ConvertFrom_ReadsFileAsString()
        {
            var resxFileRefString = @"TestResources\Files\text.ansi.txt;System.String";
            var expected          = "Text";
            var converter         = new ResXFileRef.Converter();

            var result = (string)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.Equal(expected, result);
        }
Exemplo n.º 7
0
        public void ConvertFrom_ReadsFileAsBitmap()
        {
            var resxFileRefString = @"TestResources\Files\ErrorControl.bmp;System.Drawing.Bitmap, System.Drawing.Common";
            var converter         = new ResXFileRef.Converter();

            var result = (Bitmap)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.NotNull(result);
            Assert.False(result.Size.IsEmpty);
        }
Exemplo n.º 8
0
        public void ConvertFrom_ReadsFileAsIcon()
        {
            var resxFileRefString = @"TestResources\Files\Error.ico;System.Drawing.Icon, System.Drawing.Common";
            var converter         = new ResXFileRef.Converter();

            var result = (Icon)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.NotNull(result);
            Assert.False(result.Size.IsEmpty);
        }
        public void ConvertFrom_ReadsFileAsString()
        {
            var resxFilePath      = Path.Combine("TestResources", "Files", "text.ansi.txt");
            var resxFileRefString = $"{resxFilePath};System.String";
            var expected          = "Text";
            var converter         = new ResXFileRef.Converter();

            var result = (string)converter.ConvertFrom(null, null, resxFileRefString);

            Assert.Equal(expected, result);
        }