Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit e6037e87 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

also compare tabledata

parent ca93ceab
No related branches found
No related tags found
No related merge requests found
......@@ -60,9 +60,12 @@ Module MainModule
End Function
Public Function GetRelativePath(filePath As String, basePath As String) As String
If (String.IsNullOrEmpty(filePath) OrElse String.IsNullOrEmpty(basePath)) Then
If (String.IsNullOrEmpty(filePath)) then
Return ""
End If
If (string.isnullOrempty(basePath)) Then
Return filePath
End If
If (Path.GetDirectoryName(filePath).StartsWith(basePath, StringComparison.OrdinalIgnoreCase)) Then
Return Path.GetFullPath(filePath).Substring(basePath.Length + If(basePath.EndsWith("\"), 0, 1))
End If
......
......@@ -32,6 +32,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
......@@ -153,8 +154,8 @@ namespace TUGraz.VectoCore.Tests.Utils
if (expectedEnumerable.Length > 0) {
IterateElements(expectedEnumerable, actualEnumerable, ignoredProperties);
}
} else if(propertyType == typeof(TableData)) {
// todo!
} else if(propertyType == typeof(TableData)) {
TableDataEquals(expectedVal as TableData, actualVal as TableData);
} else {
PublicPropertiesEqual(propertyType, expectedVal, actualVal, ignoredProperties);
}
......@@ -162,6 +163,36 @@ namespace TUGraz.VectoCore.Tests.Utils
}
private static void TableDataEquals(TableData expected, TableData actual)
{
Assert.NotNull(expected);
Assert.NotNull(actual);
Assert.AreEqual(expected.Columns.Count, actual.Columns.Count);
Assert.AreEqual(expected.Rows.Count, actual.Rows.Count);
foreach (DataColumn expectedCol in expected.Columns) {
Assert.NotNull(actual.Columns[expectedCol.ColumnName]);
}
//foreach (DataRow row in expected.Rows) {
for (var i = 0 ; i< expected.Rows.Count; i++) {
var expectedRow = expected.Rows[i];
var actualRow = actual.Rows[i];
foreach (DataColumn col in expected.Columns) {
var value = expectedRow[col];
if (value is ConvertedSI) {
Assert.AreEqual((value as ConvertedSI).Value, (actualRow[col] as ConvertedSI).Value);
}
if (value.GetType().IsPrimitive) {
Assert.AreEqual(value, actualRow[col]);
}
}
}
//CollectionAssert.AreEqual(expected.Rows, actual.Rows);
}
private static void IterateElements(IEnumerable<object> expected, IEnumerable<object> actual, string[] ignoredProperties = null)
{
foreach (var entry in expected.Zip(actual, Tuple.Create)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment