예제 #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));
            }
        }
예제 #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));
        }
예제 #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);
        }