Browse Source

Added tests

pull/74/merge
Halil İbrahim Kalkan 5 years ago
parent
commit
7e7db035e9
  1. 29
      test/EventHub.Domain.Tests/Events/EventTests.cs
  2. 18
      test/EventHub.Domain.Tests/Events/EventUrlHelper_Tests.cs
  3. 44
      test/EventHub.Domain.Tests/Events/Event_Tests.cs

29
test/EventHub.Domain.Tests/Events/EventTests.cs

@ -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<BusinessException>(() =>
{
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);
}
}
}

18
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);
}
}
}

44
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<BusinessException>(() =>
{
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);
}
}
}
Loading…
Cancel
Save