Sonar-Token in Jenkinsfile angepasst ExcludeFromCodeCoverage für Methode "GenerateVorgang"
This commit is contained in:
198
Hochbaustatistik.Testing/Utilities/DataOpsTest.cs
Normal file
198
Hochbaustatistik.Testing/Utilities/DataOpsTest.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using Hochbaustatistik.Business;
|
||||
using Hochbaustatistik.Database;
|
||||
using Hochbaustatistik.Utilities;
|
||||
using OpenQA.Selenium.DevTools.V109.Target;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Hochbaustatistik.Testing.Utilities
|
||||
{
|
||||
public class DataOpsTest
|
||||
{
|
||||
public readonly VorgangInpro vorgang = new VorgangInpro() { Schlussabnahme = "2022" };
|
||||
|
||||
[Theory]
|
||||
[InlineData("61/5-2-052875", "615-2-052875")]
|
||||
public void IsValidTest(string trueAz, string falseAZ)
|
||||
{
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
|
||||
Assert.True(instance.IsValid(trueAz));
|
||||
Assert.False(instance.IsValid(falseAZ));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("615-2-052875", "61/5-2-052870255", "61/5-4-050497/1", "6175-4-052875", "61/5-3-49044", "61/52052702", "Tiefe-Mark 20")]
|
||||
public void CorrectAZTest(string az1, string az2, string az3, string az4, string az5, string az6, string az7)
|
||||
{
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
|
||||
var expected1 = "61/5-2-052875";
|
||||
var expected2 = "NOT_CORRECTED";
|
||||
var expected3 = "61/5-4-050497";
|
||||
var expected4 = "61/5-4-052875";
|
||||
var expected5 = "61/5-3-049044";
|
||||
var expected6 = "61/5-2-052702";
|
||||
var expected7 = "NOT_CORRECTED";
|
||||
|
||||
Assert.Equal(expected1, instance.CorrectAZ(az1));
|
||||
Assert.Equal(expected2, instance.CorrectAZ(az2));
|
||||
Assert.Equal(expected3, instance.CorrectAZ(az3));
|
||||
Assert.Equal(expected4, instance.CorrectAZ(az4));
|
||||
Assert.Equal(expected5, instance.CorrectAZ(az5));
|
||||
Assert.Equal(expected6, instance.CorrectAZ(az6));
|
||||
Assert.Equal(expected7, instance.CorrectAZ(az7));
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("50001234567")]
|
||||
public void ReshapeIdentifikatorTest(string ident)
|
||||
{
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
var expected = "1234567";
|
||||
var actual = instance.ReshapeIdentifikator(ident);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateItnrwRecordTest()
|
||||
{
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
List<VorgangItnrw> hochbauliste = new List<VorgangItnrw>();
|
||||
hochbauliste.Add(new VorgangItnrw()
|
||||
{
|
||||
AGS = "913000",
|
||||
Identifikator = "50005733064",
|
||||
BauscheinNr = "61/5-2-43665",
|
||||
MonatGenehmigung = "5",
|
||||
JahrGenehmigung = "2017",
|
||||
NameBauherr = " ",
|
||||
Strasse = "Rüschenstr. 29",
|
||||
PLZ = "44328",
|
||||
Gemeinde = "Dortmund",
|
||||
Gemeindeteil = " ",
|
||||
Bauzustand = " ",
|
||||
Bemerkungen = " "
|
||||
});
|
||||
|
||||
var correctedAZ = "61/5-2-043665";
|
||||
var origAZ = "61/5-2-43665";
|
||||
var row = 57;
|
||||
|
||||
var hochbauListe = FileOperations.GenerateHochbauVorgangFromCSV(@"..\..\..\TestData\Testdata.csv");
|
||||
|
||||
var actual = instance.CreateItnrwRecord(row, correctedAZ, origAZ,hochbauListe);
|
||||
var expected = String.Concat("913000;", "50005733064;", "61/5-2-043665;", "5;", "2017;", " ;", "Rüschenstr. 29;", "44328;", "Dortmund;", " ;");
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateStatusBauzustandTest()
|
||||
{
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
List<string> actuals = new List<string>();
|
||||
|
||||
List<VorgangInpro> inproVorgänge = new List<VorgangInpro>()
|
||||
{
|
||||
new VorgangInpro{ Schlussabnahme = "2022" },
|
||||
new VorgangInpro { BaugenehmigungAusgeführt ="2022"}
|
||||
};
|
||||
|
||||
foreach (var item in inproVorgänge)
|
||||
{
|
||||
actuals.Add(instance.CreateStatusBauzustand(item));
|
||||
}
|
||||
|
||||
var expected1 = "F Fertigstellung erfolgte bis 31.12. des Vorjahres";
|
||||
var expected2 = "4 Baugenehmigung erloschen";
|
||||
|
||||
Assert.Equal(expected1, actuals.ElementAt(0));
|
||||
Assert.Equal(expected2, actuals.ElementAt(1));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Keine Datenbank-Verbindung möglich")]
|
||||
public void MergeInproWithITNRWTest()
|
||||
{
|
||||
var resultFile = @"C:\TEMP\hochbaustatistik.csv";
|
||||
DatabaseOperations.conString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dborap04.stadtdo.de)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=bgvp.stadtdo.de)));user id=leser;password=leser;";
|
||||
var instance = DataOpsSingleton.Instance;
|
||||
|
||||
List<VorgangItnrw> hochbauliste = new List<VorgangItnrw>();
|
||||
hochbauliste.Add(new VorgangItnrw()
|
||||
{
|
||||
AGS = "913000",
|
||||
Identifikator = "50005733064",
|
||||
BauscheinNr = "61/5-2-43665",
|
||||
MonatGenehmigung = "5",
|
||||
JahrGenehmigung = "2017",
|
||||
NameBauherr = " ",
|
||||
Strasse = "Rüschenstr. 29",
|
||||
PLZ = "44328",
|
||||
Gemeinde = "Dortmund",
|
||||
Gemeindeteil = " ",
|
||||
Bauzustand = " ",
|
||||
Bemerkungen = " "
|
||||
});
|
||||
|
||||
instance.MergeInproWithITNRW(resultFile, hochbauliste);
|
||||
Assert.True(File.Exists(resultFile));
|
||||
var result = SearchEntry(resultFile, hochbauliste[0].PLZ);
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
private bool SearchEntry(string file, string text)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
using (StreamReader sr = new StreamReader(file))
|
||||
{
|
||||
var fullText = sr.ReadToEnd();
|
||||
found = fullText.Contains(text);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Vorgänge()
|
||||
{
|
||||
var vorgänge = new List<VorgangInpro>
|
||||
{
|
||||
new VorgangInpro { Schlussabnahme = "2022" },
|
||||
new VorgangInpro { Fertigstellung_Gemeldet = "2022" },
|
||||
new VorgangInpro { BaugenehmigungAusgeführt = "2022"}
|
||||
};
|
||||
|
||||
yield return new object[] { vorgänge };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Hochbauliste()
|
||||
{
|
||||
var hochbauliste = new List<VorgangItnrw>
|
||||
{
|
||||
new VorgangItnrw {
|
||||
AGS = "913000",
|
||||
Identifikator = "50005733064",
|
||||
BauscheinNr = "61/5-2-43665",
|
||||
MonatGenehmigung = "5",
|
||||
JahrGenehmigung = "2017",
|
||||
NameBauherr = " ",
|
||||
Strasse = "Rüschenstr. 29",
|
||||
PLZ = "44328",
|
||||
Gemeinde = "Dortmund",
|
||||
Gemeindeteil = " ",
|
||||
Bauzustand = " ",
|
||||
Bemerkungen = " "}
|
||||
};
|
||||
|
||||
yield return new object[] { hochbauliste };
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Hochbaustatistik.Testing/Utilities/FileOperationsTests.cs
Normal file
27
Hochbaustatistik.Testing/Utilities/FileOperationsTests.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using Hochbaustatistik.Business;
|
||||
using Hochbaustatistik.Database;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics;
|
||||
using Hochbaustatistik.Utilities;
|
||||
|
||||
namespace Hochbaustatistik.Testing.Utilities
|
||||
{
|
||||
public class FileOperationsTests
|
||||
{
|
||||
List<VorgangItnrw> hochbauListe = new List<VorgangItnrw>();
|
||||
readonly string filePath = @"..\..\..\TestData\Testdata.csv";
|
||||
|
||||
[Fact]
|
||||
public void GenerateHochbauVorgangFromCSVTest()
|
||||
{
|
||||
hochbauListe = FileOperations.GenerateHochbauVorgangFromCSV(filePath);
|
||||
Assert.True(hochbauListe.Count != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Hochbaustatistik.Testing/Utilities/Interop.Domino.dll
Normal file
BIN
Hochbaustatistik.Testing/Utilities/Interop.Domino.dll
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user