diff --git a/test/EventHub.Application.Tests/Events/EventAppServiceTests.cs b/test/EventHub.Application.Tests/Events/EventAppServiceTests.cs index 90c4e25..581708e 100644 --- a/test/EventHub.Application.Tests/Events/EventAppServiceTests.cs +++ b/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 _eventRepository; public EventAppServiceTests() { _eventAppService = GetRequiredService(); _eventRegistrationAppService = GetRequiredService(); _testData = GetRequiredService(); + _eventRepository = GetRequiredService>(); } [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(); + } } } diff --git a/test/EventHub.Domain.Tests/Events/EventManagerTests.cs b/test/EventHub.Domain.Tests/Events/EventManagerTests.cs index 1bffcc6..714228a 100644 --- a/test/EventHub.Domain.Tests/Events/EventManagerTests.cs +++ b/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 _organizationRepository; + private readonly IRepository _eventRepository; public EventManagerTests() { _testData = GetRequiredService(); _eventManager = GetRequiredService(); _organizationRepository = GetRequiredService>(); + _eventRepository = GetRequiredService>(); } [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); + }); + } } }