Ejemplo n.º 1
0
		public void Compare(TextWriter writer)
		{
			var newFiles = new HashSet<string>(Directory.GetFiles(newDir, "*.dbc").Select((file) => new FileInfo(file).Name), 
			                                   StringComparer.InvariantCultureIgnoreCase);

			var oldFiles = new HashSet<string>(Directory.GetFiles(oldDir, "*.dbc").Select((file) => new FileInfo(file).Name),
			                                   StringComparer.InvariantCultureIgnoreCase);

			var addedFiles = newFiles.Except(oldFiles);

			var removedFiles = oldFiles.Except(newFiles);

			var existingFiles = newFiles.Except(addedFiles);

			if (addedFiles.Count() > 0)
			{
				writer.WriteLine("{0} files have been added:", addedFiles.Count());
				foreach (var file in addedFiles)
				{
					writer.WriteLine("\t" + new FileInfo(file).Name);
					var reader = new DBCReader(Path.Combine(newDir, file));
					writer.WriteLine("\t\tColumn Count: " + reader.ColumnCount);
					writer.WriteLine("\t\tRow Count: " + reader.RecordCount);
					writer.WriteLine("\t\tHas Strings: " + reader.HasStrings);
					if (reader.IrregularColumnSize)
					{
						writer.WriteLine("\t\tColumn Size IRREGULAR!");
					}
				}
			}

			if (removedFiles.Count() > 0)
			{
				writer.WriteLine("{0} files have been deprecated (not present anymore):", removedFiles.Count());
				foreach (var file in addedFiles)
				{
					writer.WriteLine("\t" + new FileInfo(file).Name);
				}
			}

			writer.WriteLine();
			writer.WriteLine("#######################################");
			writer.WriteLine("Changes in files{0}:", maxTestAmount != int.MaxValue ? " - Testing with first " + maxTestAmount + " rows" : "");
			writer.WriteLine();

			foreach (var file in existingFiles)
			{
				var comparer = new DBCFileComparer(Path.Combine(oldDir, file), Path.Combine(newDir, file), maxTestAmount, null);
				if (comparer.NewReader.IrregularColumnSize)
				{
					writer.WriteLine("Skipping {0} (IRREGULAR Column Size)", file);
				}
				else if (comparer.NewReader.ColumnCount != comparer.OldReader.ColumnCount &&
				         (comparer.NewReader.ColumnCount < 2 || comparer.OldReader.ColumnCount < 2))
				{
					writer.WriteLine("Skipping {0} (Only 1 column or less)", file);
				}
				else
				{
					comparer.Compare(writer);
				}
			}
		}
Ejemplo n.º 2
0
        public void Compare(TextWriter writer)
        {
            var newFiles = new HashSet <string>(Directory.GetFiles(newDir, "*.dbc").Select((file) => new FileInfo(file).Name),
                                                StringComparer.InvariantCultureIgnoreCase);

            var oldFiles = new HashSet <string>(Directory.GetFiles(oldDir, "*.dbc").Select((file) => new FileInfo(file).Name),
                                                StringComparer.InvariantCultureIgnoreCase);

            var addedFiles = newFiles.Except(oldFiles);

            var removedFiles = oldFiles.Except(newFiles);

            var existingFiles = newFiles.Except(addedFiles);

            if (addedFiles.Count() > 0)
            {
                writer.WriteLine("{0} files have been added:", addedFiles.Count());
                foreach (var file in addedFiles)
                {
                    writer.WriteLine("\t" + new FileInfo(file).Name);
                    var reader = new DBCReader(Path.Combine(newDir, file));
                    writer.WriteLine("\t\tColumn Count: " + reader.ColumnCount);
                    writer.WriteLine("\t\tRow Count: " + reader.RecordCount);
                    writer.WriteLine("\t\tHas Strings: " + reader.HasStrings);
                    if (reader.IrregularColumnSize)
                    {
                        writer.WriteLine("\t\tColumn Size IRREGULAR!");
                    }
                }
            }

            if (removedFiles.Count() > 0)
            {
                writer.WriteLine("{0} files have been deprecated (not present anymore):", removedFiles.Count());
                foreach (var file in addedFiles)
                {
                    writer.WriteLine("\t" + new FileInfo(file).Name);
                }
            }

            writer.WriteLine();
            writer.WriteLine("#######################################");
            writer.WriteLine("Changes in files{0}:", maxTestAmount != int.MaxValue ? " - Testing with first " + maxTestAmount + " rows" : "");
            writer.WriteLine();

            foreach (var file in existingFiles)
            {
                var comparer = new DBCFileComparer(Path.Combine(oldDir, file), Path.Combine(newDir, file), maxTestAmount, null);
                if (comparer.NewReader.IrregularColumnSize)
                {
                    writer.WriteLine("Skipping {0} (IRREGULAR Column Size)", file);
                }
                else if (comparer.NewReader.ColumnCount != comparer.OldReader.ColumnCount &&
                         (comparer.NewReader.ColumnCount < 2 || comparer.OldReader.ColumnCount < 2))
                {
                    writer.WriteLine("Skipping {0} (Only 1 column or less)", file);
                }
                else
                {
                    comparer.Compare(writer);
                }
            }
        }