Browse Source

Add missing tests for event

pull/21/head
EngincanV 6 years ago
parent
commit
964e8407a3
  1. 29
      test/EventHub.Application.Tests/Events/EventAppServiceTests.cs
  2. 28
      test/EventHub.Domain.Tests/Events/EventManagerTests.cs

29
test/EventHub.Application.Tests/Events/EventAppServiceTests.cs

@ -1,8 +1,10 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Events.Registrations;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Timing;
using Xunit;
@ -13,12 +15,14 @@ namespace EventHub.Events
private readonly IEventAppService _eventAppService;
private readonly IEventRegistrationAppService _eventRegistrationAppService;
private readonly EventHubTestData _testData;
private readonly IRepository<Event, Guid> _eventRepository;
public EventAppServiceTests()
{
_eventAppService = GetRequiredService<IEventAppService>();
_eventRegistrationAppService = GetRequiredService<IEventRegistrationAppService>();
_testData = GetRequiredService<EventHubTestData>();
_eventRepository = GetRequiredService<IRepository<Event, Guid>>();
}
[Fact]
@ -157,5 +161,30 @@ namespace EventHub.Events
result.ShouldNotBeNull();
result.Count.ShouldBeGreaterThan(1);
}
[Fact]
public async Task Should_Update_The_Event()
{
await _eventAppService.UpdateAsync(
_testData.AbpMicroservicesFutureEventId,
new UpdateEventDto
{
Title = "Updated_Microservices_Event_Title",
Description = "Updated_Microservices_Event_Description-Updated_Microservices_Event_Description-Updated_Blazor_Microservices_Description",
IsOnline = true,
Capacity = 100,
City = null,
CountryId = null,
Language = "en",
OnlineLink = null
});
var updatedEvent = await _eventRepository.GetAsync(_testData.AbpMicroservicesFutureEventId);
updatedEvent.ShouldNotBeNull();
updatedEvent.Title.ShouldBe("Updated_Microservices_Event_Title");
updatedEvent.Description.ShouldBe("Updated_Microservices_Event_Description-Updated_Microservices_Event_Description-Updated_Blazor_Microservices_Description");
updatedEvent.IsOnline.ShouldBeTrue();
}
}
}

28
test/EventHub.Domain.Tests/Events/EventManagerTests.cs

@ -1,6 +1,8 @@
using System;
using System.Threading.Tasks;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using NSubstitute;
using Shouldly;
using Volo.Abp.Domain.Repositories;
using Xunit;
@ -12,12 +14,14 @@ namespace EventHub.Events
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]
@ -41,5 +45,29 @@ namespace EventHub.Events
@event.Title.ShouldBe("Introduction to the ABP Framework");
});
}
[Fact]
public async Task Should_Update_The_Event()
{
await WithUnitOfWorkAsync(async () =>
{
var @event = await _eventRepository.GetAsync(_testData.AbpMicroservicesFutureEventId);
var updatedEvent = await _eventManager.UpdateAsync(
@event.Id,
null,
"Updated_Microservice_Event_Title",
"Updated_Microservice_Event_Description" + @event.Description,
"en",
true,
"online_link",
null,
null
);
@event.Title.ShouldBe(updatedEvent.Title);
@event.Description.ShouldBe(updatedEvent.Description);
});
}
}
}

Loading…
Cancel
Save