From 7e7db035e9c25056d15624faa0b390369ff490cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 17 Oct 2021 18:52:11 +0300 Subject: [PATCH] Added tests --- .../Events/EventTests.cs | 29 ------------ .../Events/EventUrlHelper_Tests.cs | 18 ++++++++ .../Events/Event_Tests.cs | 44 +++++++++++++++++++ 3 files changed, 62 insertions(+), 29 deletions(-) delete mode 100644 test/EventHub.Domain.Tests/Events/EventTests.cs create mode 100644 test/EventHub.Domain.Tests/Events/EventUrlHelper_Tests.cs create mode 100644 test/EventHub.Domain.Tests/Events/Event_Tests.cs diff --git a/test/EventHub.Domain.Tests/Events/EventTests.cs b/test/EventHub.Domain.Tests/Events/EventTests.cs deleted file mode 100644 index 18a23a4..0000000 --- a/test/EventHub.Domain.Tests/Events/EventTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using Shouldly; -using Volo.Abp; -using Xunit; - -namespace EventHub.Events -{ - public class EventTests - { - [Fact] - public void Should_Not_Allow_End_Time_To_Be_Earlier_Than_Start_Time() - { - var exception = Assert.Throws(() => - { - new Event( - Guid.NewGuid(), - Guid.NewGuid(), - "1a8j3v0d", - "Introduction to the ABP Framework", - DateTime.Now, - DateTime.Now.AddDays(-2), - "In this event, we will introduce the ABP Framework and explore the fundamental features." - ); - }); - - exception.Code.ShouldBe(EventHubErrorCodes.EventEndTimeCantBeEarlierThanStartTime); - } - } -} diff --git a/test/EventHub.Domain.Tests/Events/EventUrlHelper_Tests.cs b/test/EventHub.Domain.Tests/Events/EventUrlHelper_Tests.cs new file mode 100644 index 0000000..7494dff --- /dev/null +++ b/test/EventHub.Domain.Tests/Events/EventUrlHelper_Tests.cs @@ -0,0 +1,18 @@ +using Shouldly; +using Xunit; + +namespace EventHub.Events +{ + public class EventUrlHelper_Tests + { + [Theory] + [InlineData("Introducing ABP Framework!", "introducing-abp-framework")] + [InlineData("Blazor: UI Messages", "blazor-ui-messages")] + [InlineData("What's new in .NET 6", "whats-new-in-net-6")] + public void Should_Convert_Title_To_Proper_Urls(string title, string url) + { + var result = EventUrlHelper.ConvertTitleToUrlPart(title); + result.ShouldBe(url); + } + } +} \ No newline at end of file diff --git a/test/EventHub.Domain.Tests/Events/Event_Tests.cs b/test/EventHub.Domain.Tests/Events/Event_Tests.cs new file mode 100644 index 0000000..270adf0 --- /dev/null +++ b/test/EventHub.Domain.Tests/Events/Event_Tests.cs @@ -0,0 +1,44 @@ +using System; +using Shouldly; +using Volo.Abp; +using Xunit; + +namespace EventHub.Events +{ + public class Event_Tests + { + [Fact] + public void Should_Create_A_Valid_Event() + { + new Event( + Guid.NewGuid(), + Guid.NewGuid(), + "1a8j3v0d", + "Introduction to the ABP Framework", + DateTime.Now, + DateTime.Now.AddHours(2), + "In this event, we will introduce the ABP Framework..." + ); + } + + [Fact] + public void Should_Not_Allow_End_Time_Earlier_Than_Start_Time() + { + var exception = Assert.Throws(() => + { + new Event( + Guid.NewGuid(), + Guid.NewGuid(), + "1a8j3v0d", + "Introduction to the ABP Framework", + DateTime.Now, + DateTime.Now.AddDays(-2), + "In this event, we will introduce the ABP Framework..." + ); + }); + + exception.Code.ShouldBe( + EventHubErrorCodes.EventEndTimeCantBeEarlierThanStartTime); + } + } +}