Ejemplo n.º 1
0
 public void ConvertValidKnownFormatsSuccessTest(ConvertedFormat inputFormat)
 {
     foreach (var outputFormat in SignificantFormatsTestData.TestCases)
     {
         FormatProcessorBase.ClearFormatProcessorsCache();
         string         filePath1 = "file1";
         string         filePath2 = "file2";
         FormatDataItem item1     = new FormatDataItem();
         item1.SetDate("01.01.2001");
         item1.SetBrandName("brand1");
         item1.SetPrice(1111);
         FormatDataItem item2 = new FormatDataItem();
         item2.SetDate("02.02.2002");
         item2.SetBrandName("brand2");
         item2.SetPrice(2222);
         var converter = new CommonFormatConverter();
         Assert.IsNotNull(converter);
         using (var processor = converter.CreateFormatProcessor(inputFormat))
         {
             processor.AddDataItem(item1);
             processor.AddDataItem(item2);
             Assert.IsNotNull(processor);
             Assert.IsTrue(converter.ConvertProcessor(processor, filePath1, outputFormat));
             Assert.DoesNotThrow(() => converter.ConvertProcessor(processor, filePath1, outputFormat));
         }
         Assert.IsTrue(converter.Convert(filePath1, outputFormat, filePath2, inputFormat));
         Assert.DoesNotThrow(() => converter.Convert(filePath1, outputFormat, filePath2, inputFormat));
         Assert.IsTrue(converter.Convert(filePath2, inputFormat, filePath1, outputFormat));
         Assert.DoesNotThrow(() => converter.Convert(filePath2, inputFormat, filePath1, outputFormat));
         Assert.IsTrue(File.Exists(filePath1));
         Assert.IsTrue(File.Exists(filePath2));
         File.Delete(filePath1);
         File.Delete(filePath2);
     }
 }
Ejemplo n.º 2
0
        public void ConvertValidKnownFormatsDataTest(ConvertedFormat inputFormat)
        {
            string         filePath1 = "file1";
            string         filePath2 = "file2";
            FormatDataItem item1     = new FormatDataItem();

            item1.SetDate("01.01.2001");
            item1.SetBrandName("brand1");
            item1.SetPrice(1111);
            FormatDataItem item2 = new FormatDataItem();

            item2.SetDate("02.02.2002");
            item2.SetBrandName("brand2");
            item2.SetPrice(2222);
            var converter = new CommonFormatConverter();

            foreach (var outputFormat in SignificantFormatsTestData.TestCases)
            {
                FormatProcessorBase.ClearFormatProcessorsCache();
                using (var processor = converter.CreateFormatProcessor(inputFormat))
                {
                    processor.AddDataItem(item1);
                    processor.AddDataItem(item2);
                    Assert.IsTrue((FormatDataItem)processor[0] == item1);
                    Assert.IsTrue((FormatDataItem)processor[1] == item2);
                    converter.ConvertProcessor(processor, filePath1, outputFormat);
                }
                using (var processor = converter.CreateFormatProcessor(outputFormat))
                {
                    processor.ReadFromFile(filePath1);
                    Assert.IsTrue((FormatDataItem)processor[0] == item1);
                    Assert.IsTrue((FormatDataItem)processor[1] == item2);
                    converter.ConvertProcessor(processor, filePath2, inputFormat);
                }
                using (var processor = converter.CreateFormatProcessor(inputFormat))
                {
                    processor.ReadFromFile(filePath2);
                    Assert.IsTrue((FormatDataItem)processor[0] == item1);
                    Assert.IsTrue((FormatDataItem)processor[1] == item2);
                }
                File.Delete(filePath1);
                File.Delete(filePath2);
            }
        }
Ejemplo n.º 3
0
        public void ManipulateFormatDataPriceSuccess(int price)
        {
            var dataItem = new FormatDataItem();

            Assert.DoesNotThrow(() => dataItem.SetPrice(price));
        }
Ejemplo n.º 4
0
        public void ManipulateFormatDataPriceFail(int price)
        {
            var dataItem = new FormatDataItem();

            Assert.Throws <ArgumentOutOfRangeException>(() => dataItem.SetPrice(price));
        }