Skip to content

Commit 8383994

Browse files
committed
Merge branch 'feature/#95' into develop
2 parents ccfd346 + 7e9eb55 commit 8383994

File tree

14 files changed

+127
-74
lines changed

14 files changed

+127
-74
lines changed

src/Simplify.Web.Tests/Model/Validation/ValidationAttributesExecutorTests.cs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
using Simplify.Web.Model.Validation;
55
using Simplify.Web.Tests.Model.Validation.Attributes;
66
using Simplify.Web.Tests.TestEntities;
7-
using Simplify.Web.Tests.TestEntities.HierarchyValidation;
7+
using Simplify.Web.Tests.TestEntities.Inheritance;
8+
using Simplify.Web.Tests.TestEntities.Nesting;
89

910
namespace Simplify.Web.Tests.Model.Validation
1011
{
@@ -35,17 +36,16 @@ public void Validate_ModelWithOnePropertyAndOneValidateAttribute_AttributeValida
3536
}
3637

3738
[Test]
38-
public void Validate_HierarchicalModel_NestedNullAttributeException()
39+
public void Validate_NestedProperties_NestedNullAttributeException()
3940
{
4041
// Arrange
41-
var model = new RootModel
42+
var model = new NestingRootModel
4243
{
43-
//BuiltInType = "test",
44-
CustomType = new ChildModel
44+
NestedProperty = new NestedModel
4545
{
46-
//BuiltInType = "test",
47-
CustomType = new SubChildModel()
48-
}
46+
NestedProperty = new SubNestedModel()
47+
},
48+
TestInt = 1
4949
};
5050

5151
// Act
@@ -54,7 +54,24 @@ public void Validate_HierarchicalModel_NestedNullAttributeException()
5454

5555
// Assert
5656
Assert.That(ex.Message,
57-
Does.StartWith($"Required property '{nameof(SubChildModel.BuiltInType)}' is null or empty"));
57+
Does.StartWith($"Required property '{nameof(SubNestedModel.BuiltInType)}' is null or empty"));
58+
}
59+
60+
[Test]
61+
public void Validate_InheritedProperty_NestedNullAttributeException()
62+
{
63+
// Arrange
64+
var model = new InheritanceRootModel
65+
{
66+
NestedProperty = new BaseNestedModel()
67+
};
68+
69+
// Act
70+
var ex = Assert.Throws<ModelValidationException>(() => _validator.Validate(model, null));
71+
72+
// Assert
73+
Assert.That(ex.Message,
74+
Does.StartWith($"Required property '{nameof(BaseNestedModel.BuiltInType)}' is null or empty"));
5875
}
5976
}
6077
}

src/Simplify.Web.Tests/TestEntities/HierarchyValidation/BaseModel.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Simplify.Web.Tests/TestEntities/HierarchyValidation/ChildModel.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Simplify.Web.Tests/TestEntities/HierarchyValidation/RootModel.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Simplify.Web.Tests/TestEntities/HierarchyValidation/SubChildModel.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Simplify.Web.Model.Validation.Attributes;
2+
3+
#nullable disable
4+
5+
namespace Simplify.Web.Tests.TestEntities.Inheritance
6+
{
7+
public class BaseModel
8+
{
9+
[Required]
10+
public BaseNestedModel NestedProperty { get; set; }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Simplify.Web.Model.Validation.Attributes;
2+
3+
#nullable disable
4+
5+
namespace Simplify.Web.Tests.TestEntities.Inheritance
6+
{
7+
public class BaseNestedModel
8+
{
9+
[Required]
10+
public string BuiltInType { get; set; }
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#nullable disable
2+
3+
namespace Simplify.Web.Tests.TestEntities.Inheritance
4+
{
5+
public class InheritanceRootModel : BaseModel
6+
{
7+
}
8+
}

src/Simplify.Web.Tests/TestEntities/HierarchyValidation/ISubChildModel.cs renamed to src/Simplify.Web.Tests/TestEntities/Nesting/ISubNestedModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Simplify.Web.Model.Validation.Attributes;
22

3-
namespace Simplify.Web.Tests.TestEntities.HierarchyValidation
3+
namespace Simplify.Web.Tests.TestEntities.Nesting
44
{
5-
public interface ISubChildModel
5+
public interface ISubNestedModel
66
{
77
[Required]
88
string BuiltInType { get; set; }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#nullable disable
2+
3+
using Simplify.Web.Model.Validation.Attributes;
4+
5+
namespace Simplify.Web.Tests.TestEntities.Nesting
6+
{
7+
public class NestedModel
8+
{
9+
[Required]
10+
public ISubNestedModel NestedProperty { get; set; }
11+
}
12+
}

0 commit comments

Comments
 (0)