|
|
|
@@ -157,6 +157,64 @@ namespace Diligent.WebAPI.Tests.Services |
|
|
|
Assert.Equal(result.Count, 1); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetAllWithCountAsync_ShouldReturnListOfAds_WhenCalled() |
|
|
|
{ |
|
|
|
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads); |
|
|
|
AdService adService = new(databaseContext, _mapper, _technologyService, _logger); |
|
|
|
|
|
|
|
var result = await adService.GetAllWithCountAsync(); |
|
|
|
|
|
|
|
Assert.Equal(result.Count, 1); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ArchiveAd_ShouldThrowEntityNotFoundException_WhenAdDontExist() |
|
|
|
{ |
|
|
|
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads); |
|
|
|
AdService adService = new(databaseContext, _mapper, _technologyService, _logger); |
|
|
|
|
|
|
|
await Assert.ThrowsAsync<EntityNotFoundException>(async () => await adService.ArchiveAdAsync(99)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ArchiveAd_ShouldChangeExpiryDate_WhenAdExist() |
|
|
|
{ |
|
|
|
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads); |
|
|
|
AdService adService = new(databaseContext, _mapper, _technologyService, _logger); |
|
|
|
|
|
|
|
await adService.ArchiveAdAsync(2); |
|
|
|
|
|
|
|
Assert.Equal(_ads[1].ExpiredAt.Date, DateTime.Now.Date); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ImportAd_ShouldAddAdInDatabase_WhenCalled() |
|
|
|
{ |
|
|
|
AdCreateDto adCreateDto = new AdCreateDto |
|
|
|
{ |
|
|
|
Title = "Vue Developer", |
|
|
|
MinimumExperience = 0, |
|
|
|
CreatedAt = DateTime.Now, |
|
|
|
ExpiredAt = DateTime.Now.AddDays(30), |
|
|
|
KeyResponsibilities = "KR|KR", |
|
|
|
Requirements = "R|R|R", |
|
|
|
Offer = "O|O", |
|
|
|
WorkHour = "FullTime", |
|
|
|
EmploymentType = "Intership", |
|
|
|
TechnologiesIds = new List<int> { 3 } |
|
|
|
}; |
|
|
|
|
|
|
|
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads); |
|
|
|
AdService adService = new(databaseContext, _mapper, _technologyService, _logger); |
|
|
|
|
|
|
|
var ad = await adService.ImportAsync(adCreateDto); |
|
|
|
|
|
|
|
var ads = await adService.GetAllAsync(); |
|
|
|
|
|
|
|
Assert.Equal(ads.Count, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task CreateAd_ShouldAddAdIntoDatabase_WhenCalled() |
|
|
|
{ |