예제 #1
0
        public void ManipulateFormatDataMonthFail(int day, int month, int year, int newMonth)
        {
            var dataItem = new FormatDataItem();

            dataItem.SetDate(day, month, year);
            Assert.Throws <ArgumentException>(() => dataItem.SetMonth(newMonth));
        }
예제 #2
0
        public void ManipulateFormatDataDaySuccess(int day, int month, int year, int newDay)
        {
            var dataItem = new FormatDataItem();

            dataItem.SetDate(day, month, year);
            Assert.DoesNotThrow(() => dataItem.SetDay(newDay));
        }
예제 #3
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);
     }
 }
예제 #4
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);
            }
        }
예제 #5
0
        public void ManipulateFormatDataDateStringSuccess(string date)
        {
            var formatDataItem = new FormatDataItem();

            Assert.DoesNotThrow(() => formatDataItem.SetDate(date));
        }
예제 #6
0
        public void ManipulateFormatDataDateStringFail(string date)
        {
            var formatDataItem = new FormatDataItem();

            Assert.Throws <ArgumentException>(() => formatDataItem.SetDate(date));
        }