-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
161 changed files
with
3,056 additions
and
747 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
Tests/TutorLizard.BusinessLogic.Tests/Services/Browse/BrowseServiceGetAdDetailsTests.cs
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
6 changes: 3 additions & 3 deletions
6
Tests/TutorLizard.BusinessLogic.Tests/Services/Browse/BrowseServiceGetBrowseAdsPageTests.cs
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
4 changes: 2 additions & 2 deletions
4
Tests/TutorLizard.BusinessLogic.Tests/Services/Browse/BrowseServiceGetUsersScheduleTests.cs
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
2 changes: 0 additions & 2 deletions
2
Tests/TutorLizard.BusinessLogic.Tests/Services/Browse/BrowseServiceTestsBase.cs
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
77 changes: 77 additions & 0 deletions
77
...utorLizard.BusinessLogic.Tests/Services/Student/StudentServiceScheduleItemRequestTests.cs
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,77 @@ | ||
using Moq; | ||
using TutorLizard.BusinessLogic.Models; | ||
using TutorLizard.Shared.Models.DTOs.Requests; | ||
using TutorLizard.BusinessLogic.Services; | ||
|
||
namespace TutorLizard.BusinessLogic.Tests.Services.Student | ||
{ | ||
public class StudentServiceScheduleItemRequestTests : StudentServiceTestBase | ||
{ | ||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public async Task CreateScheduleItemRequest_ShouldSetIsRemoteCorrectly(bool isRemote) | ||
{ | ||
// Arrange | ||
var ad = new Ad | ||
{ | ||
Description = "Test Description", | ||
Location = "Test Location", | ||
Subject = "Test Subject", | ||
Title = "Test Title", | ||
TutorId = 2 | ||
}; | ||
var scheduleItem = new ScheduleItem { Id = 1, Ad = ad }; | ||
|
||
SetupMockGetScheduleItemById(scheduleItem); | ||
SetupMockGetAllScheduleItems(new List<ScheduleItem> { scheduleItem }); | ||
|
||
var request = new CreateScheduleItemRequestRequest | ||
{ | ||
StudentId = 3, | ||
ScheduleItemId = 1, | ||
IsRemote = isRemote | ||
}; | ||
|
||
MockScheduleItemRequestRepository | ||
.Setup(x => x.Create(It.Is<ScheduleItemRequest>(req => req.IsRemote == isRemote))) | ||
.Returns((ScheduleItemRequest req) => Task.FromResult(req)) | ||
.Verifiable(Times.Once); | ||
|
||
// Act | ||
await StudentService.CreateScheduleItemRequest(request); | ||
|
||
// Assert | ||
MockScheduleItemRequestRepository.VerifyAll(); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateScheduleItemRequest_WhenRequestSent_ShouldReturnSuccess() | ||
{ | ||
// Arrange | ||
var scheduleItem = new ScheduleItem { Id = 1 }; | ||
var studentId = 1; | ||
var isRemote = true; | ||
|
||
SetupMockGetScheduleItemById(scheduleItem); | ||
|
||
var request = new CreateScheduleItemRequestRequest | ||
{ | ||
StudentId = studentId, | ||
ScheduleItemId = scheduleItem.Id, | ||
IsRemote = isRemote | ||
}; | ||
|
||
// Act | ||
var response = await StudentService.CreateScheduleItemRequest(request); | ||
|
||
// Assert | ||
Assert.True(response.Success); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Tests/TutorLizard.BusinessLogic.Tests/Services/Student/StudentServiceTestBase.cs
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,55 @@ | ||
using AutoFixture; | ||
using Moq; | ||
using TutorLizard.BusinessLogic.Interfaces.Data.Repositories; | ||
using TutorLizard.BusinessLogic.Models; | ||
using TutorLizard.BusinessLogic.Services; | ||
|
||
namespace TutorLizard.BusinessLogic.Tests.Services.Student | ||
{ | ||
public class StudentServiceTestBase : TestsWithInMemoryDbBase | ||
{ | ||
protected StudentService StudentService; | ||
protected Fixture Fixture = new(); | ||
protected Mock<IDbRepository<Ad>> MockAdRepository = new(); | ||
protected Mock<IDbRepository<AdRequest>> MockAdRequestRepository = new(); | ||
protected Mock<IDbRepository<ScheduleItem>> MockScheduleItemRepository = new(); | ||
protected Mock<IDbRepository<ScheduleItemRequest>> MockScheduleItemRequestRepository = new(); | ||
|
||
|
||
protected StudentServiceTestBase() : base() | ||
{ | ||
StudentService = new StudentService(MockAdRepository.Object, | ||
MockAdRequestRepository.Object, | ||
MockScheduleItemRepository.Object, | ||
MockScheduleItemRequestRepository.Object); | ||
} | ||
|
||
protected void SetupMockGetScheduleItemById(ScheduleItem? scheduleItem) | ||
{ | ||
MockScheduleItemRepository | ||
.Setup(x => x.GetById(It.IsAny<int>())) | ||
.Returns(Task.FromResult(scheduleItem)); | ||
} | ||
|
||
protected void SetupMockGetAllScheduleItems(List<ScheduleItem> scheduleItems) | ||
{ | ||
var scheduleItemsInDb = AddEntitiesToInMemoryDb(scheduleItems); | ||
MockScheduleItemRepository | ||
.Setup(x => x.GetAll()) | ||
.Returns(scheduleItemsInDb); | ||
} | ||
|
||
protected IQueryable<TEntity> AddEntitiesToInMemoryDb<TEntity>(List<TEntity> entities) | ||
where TEntity : class | ||
{ | ||
DbContext | ||
.Set<TEntity>() | ||
.AddRange(entities); | ||
DbContext.SaveChanges(); | ||
|
||
return DbContext | ||
.Set<TEntity>() | ||
.AsQueryable(); | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
Tests/TutorLizard.Web.Tests/Controllers/Browse/BrowseControllerAdDetailsTests.cs
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
6 changes: 3 additions & 3 deletions
6
Tests/TutorLizard.Web.Tests/Controllers/Browse/BrowseControllerAdsTests.cs
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
4 changes: 2 additions & 2 deletions
4
Tests/TutorLizard.Web.Tests/Controllers/Browse/BrowseControllerScheduleTests.cs
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,10 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http.Json | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using static Microsoft.AspNetCore.Components.Web.RenderMode | ||
@using Microsoft.AspNetCore.Components.Web.Virtualization | ||
@using Microsoft.JSInterop | ||
@using TutorLizard.Blazor | ||
@using TutorLizard.Blazor.Components |
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,5 @@ | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
await builder.Build().RunAsync(); |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile> | ||
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TutorLizard.Shared\TutorLizard.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 was deleted.
Oops, something went wrong.
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,30 +1,19 @@ | ||
using TutorLizard.BusinessLogic.Models; | ||
using TutorLizard.BusinessLogic.Models.DTOs; | ||
using TutorLizard.Shared.Models.DTOs; | ||
|
||
namespace TutorLizard.BusinessLogic.Extensions; | ||
public static class DtoExtensions | ||
{ | ||
private static readonly ScheduleItemDto.ScheduleItemRequestStatus status; | ||
public static CategoryDto ToDto(this Category category) | ||
=> new CategoryDto(category.Id, | ||
category.Name, | ||
category.Description); | ||
|
||
public static AdDto ToDto(this Ad ad) => new AdDto(ad); | ||
public static AdRequestDto ToDto(this AdRequest adRequest) => new AdRequestDto(adRequest); | ||
public static CategoryDto ToDto(this Category category) => new CategoryDto(category); | ||
public static ScheduleItemDto ToDto(this ScheduleItem scheduleItem) => new ScheduleItemDto(scheduleItem, status); | ||
public static ScheduleItemRequestDto ToDto(this ScheduleItemRequest scheduleItemRequest) => new ScheduleItemRequestDto(scheduleItemRequest); | ||
public static UserDto ToDto(this User user) => new UserDto(user); | ||
|
||
public static AdListItemDto ToAdListItemDto(this Ad ad) | ||
{ | ||
return new AdListItemDto(id: ad.Id, | ||
tutorId: ad.TutorId, | ||
tutorName: ad.User.Name, | ||
subject: ad.Subject, | ||
title: ad.Title, | ||
description: ad.Description, | ||
categoryId: ad.CategoryId, | ||
categoryName: ad.Category.Name, | ||
price: ad.Price, | ||
location: ad.Location, | ||
isRemote: ad.IsRemote); | ||
} | ||
public static UserDto ToDto(this User user) | ||
=> new UserDto(user.Id, | ||
user.Name, | ||
user.UserType, | ||
user.Email, | ||
user.DateCreated, | ||
user.GoogleId); | ||
} |
5 changes: 2 additions & 3 deletions
5
TutorLizard.BusinessLogic/Interfaces/Data/Repositories/IUserRepository.cs
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
4 changes: 2 additions & 2 deletions
4
TutorLizard.BusinessLogic/Interfaces/Services/IBrowseService.cs
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
4 changes: 2 additions & 2 deletions
4
TutorLizard.BusinessLogic/Interfaces/Services/ICategoryService.cs
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
15 changes: 7 additions & 8 deletions
15
TutorLizard.BusinessLogic/Interfaces/Services/IStudentService.cs
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,16 +1,15 @@ | ||
using TutorLizard.BusinessLogic.Models; | ||
using TutorLizard.BusinessLogic.Models.DTOs.Requests; | ||
using TutorLizard.BusinessLogic.Models.DTOs.Responses; | ||
using TutorLizard.Shared.Models.DTOs.Requests; | ||
using TutorLizard.Shared.Models.DTOs.Responses; | ||
|
||
namespace TutorLizard.BusinessLogic.Interfaces.Services; | ||
|
||
public interface IStudentService | ||
{ | ||
Task<StudentsAcceptedAdsResponse> ViewAcceptedAds(StudentsAcceptedAdsRequest request); | ||
Task<StudentsAdRequestsResponse> ViewAdRequests(StudentsAdRequestsRequest request); | ||
Task<AdRequestStatusResponse> ViewAdRequestStatus(AdRequestStatusRequest request); | ||
Task<StudentCancelAdRequestResponse> DeleteAdRequest(StudentCancelAdRequestRequest request); | ||
Task<GetStudentsAcceptedAdsResponse> GetStudentsAcceptedAds(GetStudentsAcceptedAdsRequest request); | ||
Task<GetStudentsAdRequestsResponse> GetStudentsAdRequests(GetStudentsAdRequestsRequest request); | ||
Task<GetAdRequestStatusResponse> GetAdRequestStatus(GetAdRequestStatusRequest request); | ||
Task<DeleteAdRequestResponse> DeleteAdRequest(DeleteAdRequestRequest request); | ||
Task<CreateScheduleItemRequestResponse> CreateScheduleItemRequest(CreateScheduleItemRequestRequest request); | ||
Task<AvailableScheduleForAdResponse> GetAvailableScheduleForAd(AvailableScheduleForAdRequest request); | ||
Task<GetAvailableScheduleForAdResponse> GetAvailableScheduleForAd(GetAvailableScheduleForAdRequest request); | ||
Task<CreateAdRequestResponse> CreateAdRequest(CreateAdRequestRequest request); | ||
} |
Oops, something went wrong.