Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions CSharpExtender/CSharpExtender.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
<GenerateDocumentationFile>False</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Remove="DataAnnotations\**" />
<EmbeddedResource Remove="DataAnnotations\**" />
<None Remove="DataAnnotations\**" />
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE.txt">
<Pack>True</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Reflection;

namespace CSharpExtender.Attributes;
namespace CSharpExtender.DataAnnotations;

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class UniqueItemsAttribute : ValidationAttribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CSharpExtender.Attributes;
using CSharpExtender.DataAnnotations;
using System.ComponentModel.DataAnnotations;

namespace Test.CSharpExtender.Attributes;
namespace Test.CSharpExtender.DataAnnotations;

public class UniqueItemsAttributeTests
public class Test_UniqueItemsAttribute
{
private static ValidationContext GetValidationContext(object instance) => new(instance);

Expand Down Expand Up @@ -52,7 +52,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Contains("duplicate items", result.ErrorMessage);

Check warning on line 55 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 55 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
Assert.Contains("indices 0 and 1", result.ErrorMessage);
}

Expand All @@ -64,7 +64,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Equal("All items must be unique in the list.", result.ErrorMessage);

Check warning on line 67 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 67 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

[Fact]
Expand All @@ -85,7 +85,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Contains("duplicate items", result.ErrorMessage);

Check warning on line 88 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
Assert.Contains("indices 1 and 2", result.ErrorMessage);
}

Expand All @@ -97,7 +97,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Equal("Numbers must be unique.", result.ErrorMessage);

Check warning on line 100 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

[Fact]
Expand Down Expand Up @@ -134,7 +134,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Contains("duplicate items", result.ErrorMessage);

Check warning on line 137 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
Assert.Contains("indices 0 and 1", result.ErrorMessage);
}

Expand All @@ -154,7 +154,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Equal("Objects in the list must have unique values.", result.ErrorMessage);

Check warning on line 157 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

[Fact]
Expand All @@ -165,7 +165,7 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Contains("must be applied to a collection", result.ErrorMessage);

Check warning on line 168 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

[Fact]
Expand All @@ -176,5 +176,5 @@
var result = attribute.GetValidationResult(model.Items, GetValidationContext(model));

Assert.NotEqual(ValidationResult.Success, result);
Assert.Contains("must be applied to a collection", result.ErrorMessage);

Check warning on line 179 in Test.CSharpExtender/DataAnnotations/Test_UniqueItemsAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}
Expand Down