Esempio n. 1
0
        public void TryGetSupportedFormatFromPathFalse()
        {
            FormatProcessorBase.ClearFormatProcessorsCache();
            string filePath  = "file";
            var    converter = new CommonFormatConverter();

            Assert.IsNotNull(converter);
            ConvertedFormat format;

            if (!File.Exists(filePath) || string.IsNullOrEmpty(filePath))
            {
                Assert.Throws <ArgumentException>(() => converter.TryGetSupportedFormatFromPath("file", out format));
            }
            else
            {
                Assert.IsFalse(converter.TryGetSupportedFormatFromPath("file", out format));
            }
        }
Esempio n. 2
0
        public void TryGetSupportedFormatFromPathException(string filePath)
        {
            FormatProcessorBase.ClearFormatProcessorsCache();
            var converter = new CommonFormatConverter();

            Assert.IsNotNull(converter);
            ConvertedFormat format;

            Assert.Throws <ArgumentException>(() => converter.TryGetSupportedFormatFromPath(filePath, out format));
        }
Esempio n. 3
0
        public void TryGetSupportedFormatFromPathTrue(ConvertedFormat format)
        {
            FormatProcessorBase.ClearFormatProcessorsCache();
            var converter = new CommonFormatConverter();

            Assert.IsNotNull(converter);
            using (var processor = converter.CreateFormatProcessor(format))
            {
                Assert.IsNotNull(processor);
                Assert.IsTrue(converter.ConvertProcessor(processor, $"file.{format}", format));
            }
            ConvertedFormat supportedFormat;

            Assert.IsTrue(converter.TryGetSupportedFormatFromPath($"file.{format}", out supportedFormat));
            Assert.AreEqual(supportedFormat, format);
        }