Skip to content

Commit

Permalink
Merge branch 'develop' into feature/core-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
i4004 committed May 28, 2024
2 parents e5162b1 + a6d565e commit f2f49a0
Show file tree
Hide file tree
Showing 21 changed files with 9,344 additions and 8,709 deletions.
17,070 changes: 8,441 additions & 8,629 deletions src/SampleApps/SampleApp.Angular/ClientApp/package-lock.json

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions src/SampleApps/SampleApp.Classic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MaxAttributeTests;

[TestFixture]
public class DoubleMaxAttributeTests : AttributesTestBase
{
public const double MaxValue = 12d;

[OneTimeSetUp]
public void SetupAttribute() => Attr = new MaxAttribute(MaxValue);

[Test]
public void Validate_BelowMaxValue_Ok()
{
// Act & Assert
TestAttributeForValidValue(10d);
}

[Test]
public void Validate_MaxValueEqualsValue_Ok()
{
// Act & Assert
TestAttributeForValidValue(12d);
}

[Test]
public void Validate_AboveMaxValue_ExceptionThrown()
{
// Assign

var value = 15d;
var defaultMessage = $"Property '{nameof(TestEntityWithProperty.Prop1)}' required maximum value is {MaxValue}, actual value: {value}";

// Act & Assert
TestAttribute(value, defaultMessage);
}

[Test]
public void Validate_NullValue_NoExceptions()
{
// Act & Assert
TestAttributeForValidValue(null);
}

[Test]
public void Validate_DifferentTypes_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue((long)15.2));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using NUnit.Framework;
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes;
namespace Simplify.Web.Tests.Model.Validation.Attributes.MaxAttributeTests;

[TestFixture]
public class MaxAttributeTests : AttributesTestBase
public class IntegerMaxAttributeTests : AttributesTestBase
{
public const int MaxValue = 12;

Expand Down Expand Up @@ -42,10 +41,5 @@ public void Validate_NullValue_NoExceptions() =>
[Test]
public void Validate_DifferentTypes_ExceptionThrown() =>
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(15.2));

[Test]
public void Validate_ValueTypeNotInheritIComparable_ExceptionThrown() =>
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(new object()));
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue((long)15.2));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MaxAttributeTests;

public class LongMaxAttributeTests : AttributesTestBase
{
public const long MaxValue = 12;

[OneTimeSetUp]
public void SetupAttribute() => Attr = new MaxAttribute(MaxValue);

[Test]
public void Validate_BelowMaxValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((long)10);
}

[Test]
public void Validate_MaxValueEqualsValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((long)12);
}

[Test]
public void Validate_AboveMaxValue_ExceptionThrown()
{
// Assign

var value = (long)15;
var defaultMessage = $"Property '{nameof(TestEntityWithProperty.Prop1)}' required maximum value is {MaxValue}, actual value: {value}";

// Act & Assert
TestAttribute(value, defaultMessage);
}

[Test]
public void Validate_NullValue_NoExceptions()
{
// Act & Assert
TestAttributeForValidValue(null);
}

[Test]
public void Validate_DifferentTypes_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(15.2d));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Simplify.Web.Model.Validation.Attributes;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MaxAttributeTests;

public class MaxAttributeTestViewModel
{
[Max(1)]
public int IntParam { get; set; }

[Max((long)1)]
public long LongParam { get; set; }

[Max(1d)]
public double DoubleParam { get; set; }

[Max(typeof(decimal), "12.5")]
public decimal DecimalParam { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MaxAttributeTests;

public class TypeMaxAttributeTests : AttributesTestBase
{
public const string MaxValue = "12.5";

[OneTimeSetUp]
public void SetupAttribute() => Attr = new MaxAttribute(typeof(decimal), MaxValue);

[Test]
public void Validate_BelowMaxValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((decimal)10);
}

[Test]
public void Validate_MaxValueEqualsValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((decimal)12.5);
}

[Test]
public void Validate_AboveMaxValue_ExceptionThrown()
{
// Assign

var value = (decimal)15;
var defaultMessage = $"Property '{nameof(TestEntityWithProperty.Prop1)}' required maximum value is {MaxValue}, actual value: {value}";

// Act & Assert
TestAttribute(value, defaultMessage);
}

[Test]
public void Validate_NullValue_NoExceptions()
{
// Act & Assert
TestAttributeForValidValue(null);
}

[Test]
public void Validate_DifferentTypes_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(15.2d));
}

[Test]
public void Validate_ObjectValueIsNotIComparable_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(new object()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MinAttributeTests;

public class DoubleMinAttributeTests : AttributesTestBase
{
public const double MinValue = 12d;

[OneTimeSetUp]
public void SetupAttribute() => Attr = new MinAttribute(MinValue);

[Test]
public void Validate_AboveMinValue_Ok()
{
// Act & Assert
TestAttributeForValidValue(15d);
}

[Test]
public void Validate_MinValueEqualsValue_Ok()
{
// Act & Assert
TestAttributeForValidValue(12d);
}

[Test]
public void Validate_BelowMinValue_ExceptionThrown()
{
// Assign

var value = 8d;
var defaultMessage = $"Property '{nameof(TestEntityWithProperty.Prop1)}' required minimum value is {MinValue}, actual value: {value}";

// Act & Assert
TestAttribute(value, defaultMessage);
}

[Test]
public void Validate_NullValue_NoExceptions()
{
// Act & Assert
TestAttributeForValidValue(null);
}

[Test]
public void Validate_DifferentTypes_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue((long)12));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes;
namespace Simplify.Web.Tests.Model.Validation.Attributes.MinAttributeTests;

[TestFixture]
public class MinAttributeTests : AttributesTestBase
public class IntegerMinAttributeTests : AttributesTestBase
{
public const int MinValue = 12;

Expand Down Expand Up @@ -43,9 +43,4 @@ public void Validate_NullValue_NoExceptions() =>
public void Validate_DifferentTypes_ExceptionThrown() =>
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(12.5));

[Test]
public void Validate_ValueTypeNotInheritIComparable_ExceptionThrown() =>
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(new object()));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NUnit.Framework;
using Simplify.Web.Model.Validation.Attributes;
using System;

namespace Simplify.Web.Tests.Model.Validation.Attributes.MinAttributeTests;

public class LongMinAttributeTests : AttributesTestBase
{
public const long MinValue = 12;

[OneTimeSetUp]
public void SetupAttribute() => Attr = new MinAttribute(MinValue);

[Test]
public void Validate_AboveMinValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((long)15);
}

[Test]
public void Validate_MinValueEqualsValue_Ok()
{
// Act & Assert
TestAttributeForValidValue((long)12);
}

[Test]
public void Validate_BelowMinValue_ExceptionThrown()
{
// Assign

var value = (long)8;
var defaultMessage = $"Property '{nameof(TestEntityWithProperty.Prop1)}' required minimum value is {MinValue}, actual value: {value}";

// Act & Assert
TestAttribute(value, defaultMessage);
}

[Test]
public void Validate_NullValue_NoExceptions()
{
// Act & Assert
TestAttributeForValidValue(null);
}

[Test]
public void Validate_DifferentTypes_ExceptionThrown()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => TestAttributeForValidValue(12));
}
}
Loading

0 comments on commit f2f49a0

Please sign in to comment.