Skip to content

Commit 7cc193a

Browse files
author
Konstantin
committed
fix build error
1 parent a05551b commit 7cc193a

File tree

10 files changed

+60
-61
lines changed

10 files changed

+60
-61
lines changed

BO4ETestProject/TestBoExpansion.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace TestBO4E;
77

8+
using AwesomeAssertions;
9+
810
[TestClass]
911
public class TestBoExpansion
1012
{
@@ -20,9 +22,8 @@ public void TestBoExpansionMaLo()
2022
BusinessObject.GetExpandableFieldNames("Marktlokation").Keys
2123
);
2224
Assert.IsTrue(result.SetEquals(result2));
23-
Assert.ThrowsException<ArgumentException>(() =>
24-
BusinessObject.GetExpandableFieldNames("kein gültiges bo")
25-
);
25+
var instantiating = () => BusinessObject.GetExpandableFieldNames("kein gültiges bo");
26+
instantiating.Should().Throw<ArgumentException>();
2627
}
2728

2829
[TestMethod]

BO4ETestProject/TestBoMapperSystemText.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Text.Json;
66
using System.Threading.Tasks;
7+
using AwesomeAssertions;
78
using BO4E;
89
using BO4E.BO;
910
using BO4E.COM;
@@ -249,11 +250,12 @@ public void TestBoNameTyping()
249250
{
250251
Assert.AreEqual(typeof(Benachrichtigung), BoMapper.GetTypeForBoName("Benachrichtigung"));
251252
Assert.AreEqual(typeof(Benachrichtigung), BoMapper.GetTypeForBoName("bEnAcHriCHTIGuNg"));
252-
253-
Assert.ThrowsException<ArgumentNullException>(
254-
() => BoMapper.GetTypeForBoName(null),
255-
"null as argument must result in a ArgumentNullException"
256-
);
253+
var gettingTypeForNullName = () => BoMapper.GetTypeForBoName(null);
254+
gettingTypeForNullName
255+
.Should()
256+
.Throw<ArgumentNullException>(
257+
"null as argument must result in a ArgumentNullException"
258+
);
257259
/*
258260
bool argumentExceptionThrown = false;
259261
try

BO4ETestProject/TestEnergiemengeAdding.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using AwesomeAssertions;
34
using BO4E.BO;
45
using BO4E.COM;
56
using BO4E.ENUM;
@@ -57,6 +58,7 @@ public void TestIllegalAdd()
5758
{
5859
var em1 = new Energiemenge { LokationsId = "DE456", LokationsTyp = Lokationstyp.MELO };
5960
var em2 = new Energiemenge { LokationsId = "DE789", LokationsTyp = Lokationstyp.MELO };
60-
Assert.ThrowsException<InvalidOperationException>(() => em1 + em2);
61+
var invalidAddition = () => em1 + em2;
62+
invalidAddition.Should().Throw<InvalidOperationException>();
6163
}
6264
}

BO4ETestProject/TestExterneReferenzen.cs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using AwesomeAssertions;
34
using BO4E.BO;
45
using BO4E.COM;
56
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -21,33 +22,25 @@ public void TestGettingAndSetting()
2122
);
2223
Assert.IsTrue(marktlokation.TryGetExterneReferenz("foo", out var actualBar));
2324
Assert.AreEqual("bar", actualBar);
25+
var settingInvalidValues = () =>
26+
marktlokation.SetExterneReferenz(
27+
new ExterneReferenz { ExRefName = null, ExRefWert = "nicht bar" }
28+
);
29+
settingInvalidValues.Should().Throw<ArgumentException>();
30+
var addingInvalidValues = () =>
31+
marktlokation.SetExterneReferenz(
32+
new ExterneReferenz { ExRefName = "foo", ExRefWert = null }
33+
);
34+
addingInvalidValues.Should().Throw<ArgumentException>();
35+
var addingNull = () => marktlokation.SetExterneReferenz(null);
36+
addingNull.Should().Throw<ArgumentNullException>();
2437

25-
Assert.ThrowsException<ArgumentException>(
26-
() =>
27-
marktlokation.SetExterneReferenz(
28-
new ExterneReferenz { ExRefName = null, ExRefWert = "nicht bar" }
29-
),
30-
"must not add invalid values"
31-
);
32-
Assert.ThrowsException<ArgumentException>(
33-
() =>
34-
marktlokation.SetExterneReferenz(
35-
new ExterneReferenz { ExRefName = "foo", ExRefWert = null }
36-
),
37-
"must not add invalid values"
38-
);
39-
Assert.ThrowsException<ArgumentNullException>(
40-
() => marktlokation.SetExterneReferenz(null),
41-
"must not add null"
42-
);
38+
var settingConflictingDefaultValues = () =>
39+
marktlokation.SetExterneReferenz(
40+
new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" }
41+
);
42+
settingConflictingDefaultValues.Should().Throw<InvalidOperationException>();
4343

44-
Assert.ThrowsException<InvalidOperationException>(
45-
() =>
46-
marktlokation.SetExterneReferenz(
47-
new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" }
48-
),
49-
"By default conflicting values are rejected"
50-
);
5144
marktlokation.SetExterneReferenz(
5245
new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" },
5346
true

BO4ETestProject/TestJsonSchemaGeneration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public void BasicTest()
2626
[TestMethod]
2727
public void NegativeTest()
2828
{
29-
Assert.ThrowsException<ArgumentException>(
30-
() => BusinessObject.GetJsonSchema(typeof(string)),
31-
"Illegal types must result in a ArgumentException."
32-
);
29+
var gettingJsonSchemaOfIllegalType = () => BusinessObject.GetJsonSchema(typeof(string));
30+
gettingJsonSchemaOfIllegalType
31+
.Should()
32+
.Throw<ArgumentException>("Illegal types must result in a ArgumentException.");
3333
}
3434

3535
private const int LastDataRowOffset = 50;

BO4ETestProject/TestUserProperties.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ private void _AssertUserProperties(Messlokation melo)
107107
melo.UserProperties = null;
108108
Assert.IsFalse(melo.UserPropertyEquals("there are no user properties", "asd"));
109109
Assert.IsFalse(melo.TryGetUserProperty("there are no user properties", out string _));
110-
Assert.ThrowsException<ArgumentNullException>(() =>
110+
var invalidAttempt = () =>
111111
melo.EvaluateUserProperty<string, bool, Messlokation>(
112112
"there are no user properties",
113113
_ => default
114-
)
115-
);
114+
);
115+
invalidAttempt.Should().Throw<ArgumentNullException>();
116116
Assert.IsFalse(melo.UserPropertyEquals("myNullProp", true));
117117
}
118118

BO4ETestProject/TestZeitfenster.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using AwesomeAssertions;
23
using BO4E.COM;
34
using Microsoft.VisualStudio.TestTools.UnitTesting;
45

@@ -22,30 +23,30 @@ public void TestZeitfensterCreationFromValidString()
2223
/// Invalid string length
2324
/// </summary>
2425
[TestMethod]
25-
[ExpectedException(typeof(ArgumentException))]
2626
public void TestZeitfensterCreationFromInvalidString_Length()
2727
{
28-
var zeitfenster = new Zeitfenster("090017");
28+
var instantiating = () => new Zeitfenster("090017");
29+
instantiating.Should().Throw<ArgumentException>();
2930
}
3031

3132
/// <summary>
3233
/// Invalid format (non-numeric)
3334
/// </summary>
3435
[TestMethod]
35-
[ExpectedException(typeof(ArgumentException))]
3636
public void TestZeitfensterCreationFromInvalidString_Format()
3737
{
38-
var zeitfenster = new Zeitfenster("09XX1700");
38+
var instantiating = () => new Zeitfenster("09XX1700");
39+
instantiating.Should().Throw<ArgumentException>();
3940
}
4041

4142
/// <summary>
4243
/// Invalid time (hours >= 24 or minutes >= 60)
4344
/// </summary>
4445
[TestMethod]
45-
[ExpectedException(typeof(ArgumentException))]
4646
public void TestZeitfensterCreationFromInvalidString_InvalidTime()
4747
{
48-
var zeitfenster = new Zeitfenster("24611700");
48+
var instantiating = () => new Zeitfenster("24611700");
49+
instantiating.Should().Throw<ArgumentException>();
4950
}
5051

5152
/// <summary>

TestBO4E.Extensions/TestMengeneinheitExtension.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using AwesomeAssertions;
23
using BO4E.ENUM;
34
using BO4E.Extensions.ENUM;
45
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -41,10 +42,12 @@ public void TestConversionFactor()
4142
foreach (Mengeneinheit me2 in Enum.GetValues(typeof(Mengeneinheit)))
4243
if (!me1.IsConvertibleTo(me2))
4344
{
44-
Assert.ThrowsException<InvalidOperationException>(
45-
() => me1.GetConversionFactor(me2),
46-
$"Conversion {me1}-->{me2} should throw an exception!"
47-
);
45+
var gettingConversionFactor = () => me1.GetConversionFactor(me2);
46+
gettingConversionFactor
47+
.Should()
48+
.Throw<InvalidOperationException>(
49+
$"Conversion {me1}-->{me2} should throw an exception!"
50+
);
4851
}
4952
}
5053
}

TestBO4E.Extensions/TestVerbrauchExtension.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,7 @@ public void TestUnitConversion()
480480
v1.ConvertToUnit(Mengeneinheit.KW);
481481
Assert.AreEqual(Mengeneinheit.KW, v1.Einheit);
482482
Assert.AreEqual(17000.0M, v1.Wert);
483-
484-
Assert.ThrowsException<InvalidOperationException>(() =>
485-
v1.ConvertToUnit(Mengeneinheit.KWH)
486-
);
483+
var invalidConversionAttempt = () => v1.ConvertToUnit(Mengeneinheit.KWH);
484+
invalidConversionAttempt.Should().Throw<InvalidOperationException>();
487485
}
488486
}

TestBO4E.Reporting/TestReportToCsv.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading;
5+
using AwesomeAssertions;
56
using BO4E.BO;
67
using BO4E.COM;
78
using BO4E.ENUM;
@@ -335,9 +336,8 @@ public void TestCompletenessReportToCsvExceptions()
335336
null,
336337
};
337338
var newResult = string.Empty;
338-
Assert.ThrowsException<ArgumentNullException>(() =>
339-
cr.ToCsv(';', true, Environment.NewLine, reihenfolge)
340-
);
339+
var invalidToCsv1 = () => cr.ToCsv(';', true, Environment.NewLine, reihenfolge);
340+
invalidToCsv1.Should().Throw<ArgumentNullException>();
341341
Assert.AreEqual(newResult, "");
342342

343343
// reihenfolge
@@ -352,9 +352,8 @@ public void TestCompletenessReportToCsvExceptions()
352352
new Dictionary<string, string> { ["enddatum"] = "V.enddatum" },
353353
new Dictionary<string, string> { ["asdasd"] = "000" },
354354
};
355-
Assert.ThrowsException<ArgumentException>(() =>
356-
cr.ToCsv(';', true, Environment.NewLine, reihenfolge2)
357-
);
355+
var invalidToCsv = () => cr.ToCsv(';', true, Environment.NewLine, reihenfolge2);
356+
invalidToCsv.Should().Throw<ArgumentException>();
358357
Assert.AreEqual(newResult, "");
359358
}
360359

0 commit comments

Comments
 (0)