Skip to content

Commit

Permalink
Fixed build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
karlssberg committed Jul 24, 2024
1 parent 267f42a commit b2c53dd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
10 changes: 3 additions & 7 deletions Motiv.Tests/Customizations/InternalConstructorCustomization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,14 @@ private bool IsAssignableToGenericType(Type givenType, Type genericType)
{
var interfaceTypes = givenType.GetInterfaces();

foreach (var it in interfaceTypes)
if (interfaceTypes.Any(it => it.IsGenericType && it.GetGenericTypeDefinition() == genericType))
{
if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType)
return true;
return true;
}

if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
return true;

Type baseType = givenType.BaseType;
if (baseType == null) return false;

return IsAssignableToGenericType(baseType, genericType);
return givenType.BaseType != null && IsAssignableToGenericType(givenType.BaseType, genericType);
}
}
4 changes: 2 additions & 2 deletions Motiv.Tests/HigherOrderProposition/BooleanResultTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Constructor_WhenGivenValidParameters_InitializesProperties(
public void Constructor_WhenGivenNullModel_ThrowsArgumentNullException(
BooleanResultBase<string> underlyingResult)
{
Action act = () => new BooleanResult<string, string>(null, underlyingResult);
var act = () => new BooleanResult<string, string>(null!, underlyingResult);

act.Should().Throw<ArgumentNullException>().WithParameterName("model");
}
Expand All @@ -35,7 +35,7 @@ public void Constructor_WhenGivenNullModel_ThrowsArgumentNullException(
public void Constructor_WhenGivenNullUnderlyingResult_ThrowsArgumentNullException(
string model)
{
Action act = () => new BooleanResult<string, string>(model, null);
var act = () => new BooleanResult<string, string>(model, null!);

act.Should().Throw<ArgumentNullException>().WithParameterName("underlyingResult");
}
Expand Down
7 changes: 3 additions & 4 deletions Motiv.Tests/HigherOrderProposition/PolicyResultTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ namespace Motiv.Tests.HigherOrderProposition;

public class PolicyResultTests
{
[Theory]
[AutoData]
[Fact]
public void Constructor_ShouldThrowArgumentNullException_WhenModelIsNull()
{
// Act & Assert
var underlyingResult = Substitute.For<PolicyResultBase<TestMetadata>>();

Action act = () => new PolicyResult<TestModel, TestMetadata>(null, underlyingResult);
var act = () => new PolicyResult<TestModel, TestMetadata>(null!, underlyingResult);

act.Should().Throw<ArgumentNullException>();
}
Expand All @@ -24,7 +23,7 @@ public void Constructor_ShouldThrowArgumentNullException_WhenUnderlyingResultIsN
TestModel model)
{
// Act & Assert
Action act = () => new PolicyResult<TestModel, TestMetadata>(model, null);
var act = () => new PolicyResult<TestModel, TestMetadata>(model, null!);
act.Should().Throw<ArgumentNullException>();
}

Expand Down
2 changes: 1 addition & 1 deletion Motiv.Tests/HigherOrderProposition/TestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public class TestModel
{
public int Id { get; set; }
public string Name { get; set; }
public string? Name { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Motiv.BooleanPredicateProposition;
/// <param name="satisfied">The value of the proposition.</param>
/// <param name="metadataTier">The metadata to yield when the predicate is true.</param>
/// <param name="explanation">The explanation of the proposition.</param>
/// <param name="reason">The reason for the proposition.</param>
/// <param name="description">The reasons for the result.</param>
/// <typeparam name="TMetadata">The type of the metadata.</typeparam>
internal sealed class PropositionBooleanResult<TMetadata>(
bool satisfied,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// Represents a proposition that yields custom metadata based on the result of a boolean predicate.
/// </summary>
/// <param name="satisfied">The value of the proposition.</param>
/// <param name="lazyValue">The value of the policy result.</param>
/// <param name="metadataTier">The metadata to yield when the predicate is true.</param>
/// <param name="explanation">The explanation of the proposition.</param>
/// <param name="description">The description of the proposition result.</param>
Expand Down

0 comments on commit b2c53dd

Please sign in to comment.