mirror of https://github.com/abpframework/eventhub
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.3 KiB
66 lines
2.3 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using EventHub.Events.Registrations;
|
|
using EventHub.Organizations;
|
|
using NSubstitute;
|
|
using Shouldly;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Xunit;
|
|
|
|
namespace EventHub.Events
|
|
{
|
|
public class EventManagerTests : EventHubDomainTestBase
|
|
{
|
|
private readonly EventHubTestData _testData;
|
|
private readonly EventManager _eventManager;
|
|
private readonly IRepository<Organization, Guid> _organizationRepository;
|
|
private readonly IRepository<Event, Guid> _eventRepository;
|
|
|
|
public EventManagerTests()
|
|
{
|
|
_testData = GetRequiredService<EventHubTestData>();
|
|
_eventManager = GetRequiredService<EventManager>();
|
|
_organizationRepository = GetRequiredService<IRepository<Organization, Guid>>();
|
|
_eventRepository = GetRequiredService<IRepository<Event, Guid>>();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Should_Create_A_Valid_Event()
|
|
{
|
|
await WithUnitOfWorkAsync(async () =>
|
|
{
|
|
var volosoftOrganization = await _organizationRepository.GetAsync(
|
|
_testData.OrganizationVolosoftId
|
|
);
|
|
|
|
var @event = await _eventManager.CreateAsync(
|
|
volosoftOrganization,
|
|
"Introduction to the ABP Framework",
|
|
DateTime.Now.AddDays(1),
|
|
DateTime.Now.AddDays(1).AddHours(3),
|
|
"In this event, we will introduce the ABP Framework and explore the fundamental features."
|
|
);
|
|
|
|
@event.OrganizationId.ShouldBe(volosoftOrganization.Id);
|
|
@event.Title.ShouldBe("Introduction to the ABP Framework");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Should_Update_The_Event_Capacity()
|
|
{
|
|
await WithUnitOfWorkAsync(async () =>
|
|
{
|
|
var @event = await _eventRepository.GetAsync(_testData.AbpMicroservicesFutureEventId);
|
|
var newCapacity = @event.Capacity.HasValue ? @event.Capacity.Value + 1 : 42;
|
|
|
|
await _eventManager.SetCapacityAsync(
|
|
@event,
|
|
newCapacity
|
|
);
|
|
|
|
@event.Capacity.ShouldBe(newCapacity);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|