コード例 #1
0
        internal static AutoprefixerLoadException WrapAutoprefixerLoadException(Exception exception,
                                                                                bool quoteDescription = false)
        {
            string description = exception.Message;
            string message     = GenerateAutoprefixerLoadErrorMessage(description, quoteDescription);

            var autoprefixerLoadException = new AutoprefixerLoadException(message, exception)
            {
                Description = description
            };

            return(autoprefixerLoadException);
        }
コード例 #2
0
        public void MappingJsonError()
        {
            // Arrange
            var options = new ProcessingOptions
            {
                Browsers = new List <string> {
                    "> 5% in my stats"
                },
                Stats = @"{
  ""ie"": {
    ""6"": 0.01,
    ""7"": 0.4,
    ""8"": 1.5
  },
  ""chrome"": {
    …
  },
  …
}"
            };

            // Act
            AutoprefixerLoadException exception = null;

            try
            {
                using (var autoprefixer = new Autoprefixer(options))
                { }
            }
            catch (AutoprefixerLoadException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
            Assert.AreEqual("The value of 'Stats' property has an incorrect format.", exception.Message);
            Assert.AreEqual("The value of 'Stats' property has an incorrect format.", exception.Description);
        }
コード例 #3
0
        public void MappingJavaScriptError()
        {
            // Arrange
            IJsEngineFactory jsEngineFactory = new JintJsEngineFactory();
            const string     input           = @".some-class {
    border-image: linear-gradient(black, white) 20% fill stretch stretch;
}";

            // Act
            string output;
            AutoprefixerLoadException exception = null;

            try
            {
                using (var autoprefixer = new Autoprefixer(jsEngineFactory))
                {
                    output = autoprefixer.Process(input).ProcessedContent;
                }
            }
            catch (AutoprefixerLoadException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
            Assert.AreEqual(
                "During loading of the Autoprefixer error has occurred. " +
                "See the original error message: \"ReferenceError: Uint8Array is not defined" + Environment.NewLine +
                "   at AutoprefixerHost.Resources.autoprefixer-combined.min.js:46:9781\".",
                exception.Message
                );
            Assert.AreEqual(
                "ReferenceError: Uint8Array is not defined" + Environment.NewLine +
                "   at AutoprefixerHost.Resources.autoprefixer-combined.min.js:46:9781",
                exception.Description
                );
        }