From d176ed06289cd2988797288069724ecd80812e90 Mon Sep 17 00:00:00 2001 From: Gary Woodfine Date: Wed, 1 Jun 2022 20:10:17 +0100 Subject: [PATCH] Added Unit test and modified ErrorKeyNames.cs --- src/ApiResponse/ErrorKeyNames.cs | 2 +- tests/Unit/ListResponseTests.cs | 22 +++++++++++++++++++++- tests/Unit/SIngleResponseTests.cs | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/SIngleResponseTests.cs diff --git a/src/ApiResponse/ErrorKeyNames.cs b/src/ApiResponse/ErrorKeyNames.cs index 8570ea8..64d0650 100644 --- a/src/ApiResponse/ErrorKeyNames.cs +++ b/src/ApiResponse/ErrorKeyNames.cs @@ -4,6 +4,6 @@ public static class ErrorKeyNames { public const string Conflict = "conflict"; public const string Validation = "validation"; - public const string NotFound = "not-found"; + public const string NotFound = "notfound"; } \ No newline at end of file diff --git a/tests/Unit/ListResponseTests.cs b/tests/Unit/ListResponseTests.cs index 3114807..e41f540 100644 --- a/tests/Unit/ListResponseTests.cs +++ b/tests/Unit/ListResponseTests.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -43,8 +44,27 @@ public void Should_set_and_get_properties() } - } + + [Theory, Description("Ensure ListResponse has properties defined")] + [InlineData("Items", typeof(List))] + [InlineData("Size", typeof(int))] + [InlineData("Page", typeof(int))] + [InlineData("PerPage", typeof(int))] + [InlineData("TotalPages", typeof(int))] + [InlineData("HasPrevious", typeof(bool))] + [InlineData("HasNext", typeof(bool))] + public void Should_have_base_fields_defined(string name, Type type) + { + var testClass = typeof(ListResponse); + var prop = testClass.GetProperty(name); + prop.ShouldSatisfyAllConditions( + () => prop.ShouldNotBeNull(), + () => prop?.PropertyType.ShouldBeEquivalentTo(type) + ); + } + } + public class DummyListResponseClass { public string Name { get; set; } diff --git a/tests/Unit/SIngleResponseTests.cs b/tests/Unit/SIngleResponseTests.cs new file mode 100644 index 0000000..b6606e9 --- /dev/null +++ b/tests/Unit/SIngleResponseTests.cs @@ -0,0 +1,27 @@ +using System; +using System.ComponentModel; +using Shouldly; +using Xunit; + +namespace Threenine.ApiResponse.Tests; + +public class SIngleResponseTests +{ + [Theory, Description("Ensure SingleResponse has properties defined")] + [InlineData("Item", typeof(TestClass))] + public void Should_have_base_fields_defined(string name, Type type) + { + var testClass = typeof(SingleResponse); + var prop = testClass.GetProperty(name); + + prop.ShouldSatisfyAllConditions( + () => prop.ShouldNotBeNull(), + () => prop?.PropertyType.ShouldBeEquivalentTo(type) + ); + } +} + +public class TestClass +{ + +} \ No newline at end of file