Skip to content

Commit

Permalink
Simplify usings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Jul 31, 2023
1 parent bf2f6e1 commit beef050
Show file tree
Hide file tree
Showing 27 changed files with 3,030 additions and 3,188 deletions.
60 changes: 27 additions & 33 deletions specs/Qowaiv.Specs/Cast_specs.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
using NUnit.Framework;
using Qowaiv;
using Qowaiv.Financial;
using Qowaiv.TestTools;
namespace Cast_specs;

namespace Cast_specs
public class Invalid
{
public class Invalid
{
[TestCase(double.MaxValue)]
[TestCase(double.MinValue)]
[TestCase(double.NaN)]
[TestCase(double.NegativeInfinity)]
[TestCase(double.PositiveInfinity)]
public void double_to_Percentage(double num) => QAssert.InvalidCast(() => (Percentage)num);
[TestCase(double.MaxValue)]
[TestCase(double.MinValue)]
[TestCase(double.NaN)]
[TestCase(double.NegativeInfinity)]
[TestCase(double.PositiveInfinity)]
public void double_to_Percentage(double num) => QAssert.InvalidCast(() => (Percentage)num);

[TestCase(double.MaxValue)]
[TestCase(double.MinValue)]
[TestCase(double.NaN)]
[TestCase(double.NegativeInfinity)]
[TestCase(double.PositiveInfinity)]
public void double_to_Amount(double num) => QAssert.InvalidCast(() => (Amount)num);
[TestCase(double.MaxValue)]
[TestCase(double.MinValue)]
[TestCase(double.NaN)]
[TestCase(double.NegativeInfinity)]
[TestCase(double.PositiveInfinity)]
public void double_to_Amount(double num) => QAssert.InvalidCast(() => (Amount)num);


[TestCase(int.MaxValue)]
[TestCase(1_000_000_000)]
public void int_to_HouseNumber(int num) => QAssert.InvalidCast(() => (HouseNumber)num);
[TestCase(int.MaxValue)]
[TestCase(1_000_000_000)]
public void int_to_HouseNumber(int num) => QAssert.InvalidCast(() => (HouseNumber)num);

[TestCase(int.MaxValue)]
[TestCase(1_000_000)]
[TestCase(-1)]
[TestCase(13)]
public void int_to_Month(int num) => QAssert.InvalidCast(() => (Month)num);
[TestCase(int.MaxValue)]
[TestCase(1_000_000)]
[TestCase(-1)]
[TestCase(13)]
public void int_to_Month(int num) => QAssert.InvalidCast(() => (Month)num);

[TestCase(int.MaxValue)]
[TestCase(1_000_000)]
[TestCase(-1)]
[TestCase(10_000)]
public void int_to_Year(int num) => QAssert.InvalidCast(() => (Year)num);
}
[TestCase(int.MaxValue)]
[TestCase(1_000_000)]
[TestCase(-1)]
[TestCase(10_000)]
public void int_to_Year(int num) => QAssert.InvalidCast(() => (Year)num);
}
127 changes: 58 additions & 69 deletions specs/Qowaiv.Specs/Debug_specs.cs
Original file line number Diff line number Diff line change
@@ -1,85 +1,74 @@
using FluentAssertions;
using NUnit.Framework;
using Qowaiv.Formatting;
using Qowaiv.Globalization;
using Qowaiv.Json;
using Qowaiv.Text;
using System;
using System.Diagnostics;
using System.Globalization;
namespace Debug_specs;

namespace Debug_specs
public class Type_is
{
public class Type_is
{
[TestCase(typeof(CultureInfoScope))]
[TestCase(typeof(FormattingArguments))]
[TestCase(typeof(PostalCodeCountryInfo))]
[TestCase(typeof(WildcardPattern))]
public void decorated_with_DebuggerDisplay_attribute(Type svoType)
=> svoType.Should().BeDecoratedWith<DebuggerDisplayAttribute>();
}
[TestCase(typeof(CultureInfoScope))]
[TestCase(typeof(FormattingArguments))]
[TestCase(typeof(PostalCodeCountryInfo))]
[TestCase(typeof(WildcardPattern))]
public void decorated_with_DebuggerDisplay_attribute(Type svoType)
=> svoType.Should().BeDecoratedWith<DebuggerDisplayAttribute>();
}

public class Debugger_displays
public class Debugger_displays
{
[Test]
public void Open_API_data()
{
[Test]
public void Open_API_data()
{
var attribute = new OpenApiDataTypeAttribute(
description: "Year",
example: "1983",
type: "integer",
format: "0000",
nullable: true,
pattern: "^[0-9]{4}$");
var attribute = new OpenApiDataTypeAttribute(
description: "Year",
example: "1983",
type: "integer",
format: "0000",
nullable: true,
pattern: "^[0-9]{4}$");

attribute.Should().HaveDebuggerDisplay("{ type: integer, desc: Year, example: 1983, format: 0000, pattern: ^[0-9]{4}$, nullable: true }");
}
attribute.Should().HaveDebuggerDisplay("{ type: integer, desc: Year, example: 1983, format: 0000, pattern: ^[0-9]{4}$, nullable: true }");
}

[Test]
public void empty_postal_code_country_data_for_empty_country()
=> PostalCodeCountryInfo.GetInstance(Country.Empty)
.Should().HaveDebuggerDisplay("Postal code[], none");
[Test]
public void empty_postal_code_country_data_for_empty_country()
=> PostalCodeCountryInfo.GetInstance(Country.Empty)
.Should().HaveDebuggerDisplay("Postal code[], none");

[Test]
public void postal_code_pattern_and_county_for_county_with_postal_codes()
=> PostalCodeCountryInfo.GetInstance(Country.BE)
.Should().HaveDebuggerDisplay("Postal code[BE], Pattern: ^[1-9][0-9]{3}$");
[Test]
public void postal_code_pattern_and_county_for_county_with_postal_codes()
=> PostalCodeCountryInfo.GetInstance(Country.BE)
.Should().HaveDebuggerDisplay("Postal code[BE], Pattern: ^[1-9][0-9]{3}$");

[Test]
public void postal_code_value_and_county_for_county_with_one_postal_code()
=> PostalCodeCountryInfo.GetInstance(Country.VA)
.Should().HaveDebuggerDisplay("Postal code[VA], Value: 00120");
[Test]
public void postal_code_value_and_county_for_county_with_one_postal_code()
=> PostalCodeCountryInfo.GetInstance(Country.VA)
.Should().HaveDebuggerDisplay("Postal code[VA], Value: 00120");

[Test]
public void current_and_previous_cultures_for_culture_info_scope()
[Test]
public void current_and_previous_cultures_for_culture_info_scope()
{
using (new CultureInfoScope("en-NL", "en-US"))
{
using (new CultureInfoScope("en-NL", "en-US"))
{
using var scope = new CultureInfoScope("es-ES", "fr-FR");
scope.Should().HaveDebuggerDisplay("CultureInfoScope: [es-ES/fr-FR], Previous: [en-NL/en-US]");
}
using var scope = new CultureInfoScope("es-ES", "fr-FR");
scope.Should().HaveDebuggerDisplay("CultureInfoScope: [es-ES/fr-FR], Previous: [en-NL/en-US]");
}

[Test]
public void formatting_arguments_without_pattern_if_not_specified()
=> ((object)new FormattingArgumentsCollection(new CultureInfo("en-GB")))
.Should().HaveDebuggerDisplay("FormattingArgumentsCollection: 'en-GB', Items: 0");
}

[Test]
public void formatting_arguments_without_pattern_if_not_specified()
=> ((object)new FormattingArgumentsCollection(new CultureInfo("en-GB")))
.Should().HaveDebuggerDisplay("FormattingArgumentsCollection: 'en-GB', Items: 0");

[Test]
public void formatting_arguments_with_pattern_if_specified()
=> new FormattingArguments("yyyy-MM-dd", new CultureInfo("en-GB"))
.Should().HaveDebuggerDisplay("Format: 'yyyy-MM-dd', Provider: en-GB");

[Test]
public void wildcard_pattern()
=> new WildcardPattern("t?st*")
.Should().HaveDebuggerDisplay("{t?st*}");
[Test]
public void formatting_arguments_with_pattern_if_specified()
=> new FormattingArguments("yyyy-MM-dd", new CultureInfo("en-GB"))
.Should().HaveDebuggerDisplay("Format: 'yyyy-MM-dd', Provider: en-GB");

[Test]
public void wildcard_pattern_with_options_if_not_default()
=> new WildcardPattern("t?st*", WildcardPatternOptions.SingleOrTrailing, StringComparison.Ordinal)
.Should().HaveDebuggerDisplay("{t?st*}, SingleOrTrailing, Ordinal");
}
[Test]
public void wildcard_pattern()
=> new WildcardPattern("t?st*")
.Should().HaveDebuggerDisplay("{t?st*}");

[Test]
public void wildcard_pattern_with_options_if_not_default()
=> new WildcardPattern("t?st*", WildcardPatternOptions.SingleOrTrailing, StringComparison.Ordinal)
.Should().HaveDebuggerDisplay("{t?st*}, SingleOrTrailing, Ordinal");
}
18 changes: 6 additions & 12 deletions specs/Qowaiv.Specs/Extensions/Enumerable_specs.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using FluentAssertions;
using NUnit.Framework;
using Qowaiv.Statistics;
using System.Linq;
namespace Extensions.Enumerable_specs;

namespace Extensions.Enumerable_specs
public class Average
{
public class Average
[Test]
public void Elo()
{
[Test]
public void Elo()
{
var elos = new Elo[] { 1400, 1600 };
elos.Average().Should().Be(1500.Elo());
}
var elos = new Elo[] { 1400, 1600 };
elos.Average().Should().Be(1500.Elo());
}
}
4 changes: 1 addition & 3 deletions specs/Qowaiv.Specs/MonthSpan_specs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NUnit.Framework.Interfaces;

namespace MonthSpan_specs;
namespace MonthSpan_specs;

public class Is_equal_by_value
{
Expand Down

0 comments on commit beef050

Please sign in to comment.