-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #559 from henriqueholtz/develop
Turning endpoints of `ContactUsController` and `MeetupController` as async
- Loading branch information
Showing
18 changed files
with
152 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using ShareBook.Domain; | ||
using ShareBook.Domain.Common; | ||
using System.Threading.Tasks; | ||
|
||
namespace ShareBook.Service | ||
{ | ||
public interface IContactUsService | ||
{ | ||
Result<ContactUs> SendContactUs(ContactUs contactUs, string recaptchaReactive); | ||
Task<Result<ContactUs>> SendContactUsAsync(ContactUs contactUs, string recaptchaReactive); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
namespace ShareBook.Service.Upload | ||
using System.Threading.Tasks; | ||
|
||
namespace ShareBook.Service.Upload | ||
{ | ||
public interface IUploadService | ||
{ | ||
string UploadImage(byte[] imageBytes, string imageName, string lastDirectory); | ||
string UploadPdf(byte[] imageBytes, string imageName, string lastDirectory); | ||
Task<string> UploadImageAsync(byte[] imageBytes, string imageName, string lastDirectory); | ||
Task<string> UploadPdfAsync(byte[] imageBytes, string imageName, string lastDirectory); | ||
string GetImageUrl(string imageName, string lastDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Moq; | ||
using Sharebook.Jobs; | ||
using ShareBook.Service; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using ShareBook.Repository; | ||
using Microsoft.Extensions.Configuration; | ||
using ShareBook.Domain.Enums; | ||
using System.Collections.Generic; | ||
using ShareBook.Domain; | ||
|
||
namespace ShareBook.Test.Unit.Jobs | ||
{ | ||
public class MeetupSearchTests | ||
{ | ||
private readonly Mock<IJobHistoryRepository> _mockJobHistoryRepository = new(); | ||
private readonly Mock<IMeetupService> _mockMeetupService = new(); | ||
private readonly Mock<IConfiguration> _mockConfiguration = new(); | ||
|
||
[Fact] | ||
public async Task MeetupSettingsDisabled_ShouldReturn_MeetupDisabled() | ||
{ | ||
_mockConfiguration.SetupGet(s => s[It.IsAny<string>()]).Returns("false"); | ||
MeetupSearch job = new MeetupSearch(_mockJobHistoryRepository.Object, _mockMeetupService.Object, _mockConfiguration.Object); | ||
|
||
JobResult result = await job.ExecuteAsync(); | ||
Assert.Equal(JobResult.MeetupDisabled, result); | ||
_mockMeetupService.VerifyNoOtherCalls(); | ||
_mockJobHistoryRepository.VerifyNoOtherCalls(); | ||
} | ||
|
||
[Fact] | ||
public async Task MeetupSettingsEnabled_ShouldReturn_MeetupsCorrectly() | ||
{ | ||
List<string> mockedMeetups = new List<string> { "Meetup Mock 1", "Meetup Mock 2" }; | ||
_mockConfiguration.SetupGet(s => s[It.IsAny<string>()]).Returns("true"); | ||
_mockMeetupService.Setup(s => s.FetchMeetupsAsync()).ReturnsAsync(() => mockedMeetups); | ||
MeetupSearch job = new MeetupSearch(_mockJobHistoryRepository.Object, _mockMeetupService.Object, _mockConfiguration.Object); | ||
|
||
JobHistory result = await job.WorkAsync(); | ||
Assert.Equal("MeetupSearch", result.JobName); | ||
Assert.True(result.IsSuccess); | ||
Assert.Equal(string.Join("\n", mockedMeetups), result.Details); | ||
_mockMeetupService.Verify(c => c.FetchMeetupsAsync(), Times.Once); | ||
_mockMeetupService.VerifyNoOtherCalls(); | ||
_mockJobHistoryRepository.VerifyNoOtherCalls(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.