Skip to content

Commit

Permalink
Merge pull request #32 from eduardo-paes:development
Browse files Browse the repository at this point in the history
Complete test implementation
  • Loading branch information
eduardo-paes authored Nov 1, 2023
2 parents b0f0877 + f26b0b2 commit a6a2296
Show file tree
Hide file tree
Showing 132 changed files with 6,716 additions and 320 deletions.
6 changes: 6 additions & 0 deletions src/Application.Tests/Application.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@
<None Remove="FluentAssertions" />
</ItemGroup>

<ItemGroup>
<None Update="Samples/*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions src/Application.Tests/Mocks/ActivityTypeMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class ActivityTypeMock
{
public static ActivityType MockValidActivityType()
{
return new ActivityType("Activity Type Name", "Activity Type Description", Guid.NewGuid());
}
}
}
9 changes: 9 additions & 0 deletions src/Application.Tests/Mocks/CampusMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class CampusMock
{
public static Campus MockValidCampus() => new("Campus Name");
}
}
7 changes: 7 additions & 0 deletions src/Application.Tests/Mocks/ClaimsMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Application.Tests.Mocks
{
public static class ClaimsMock
{
public static Dictionary<Guid, Domain.Entities.User> MockValidClaims() => new() { { Guid.NewGuid(), UserMock.MockValidUser() } };
}
}
9 changes: 9 additions & 0 deletions src/Application.Tests/Mocks/CourseMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class CourseMock
{
public static Course MockValidCourse() => new("Course Name");
}
}
18 changes: 18 additions & 0 deletions src/Application.Tests/Mocks/FileMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Http;
using Moq;

namespace Application.Tests.Mocks
{
public static class FileMock
{
public static IFormFile CreateIFormFile()
{
// Create a mock IFormFile, you can adjust the implementation as needed.
var fileMock = new Mock<IFormFile>();
fileMock.Setup(file => file.FileName).Returns("file.txt");
fileMock.Setup(file => file.Length).Returns(1024);
// Add other setup as needed.
return fileMock.Object;
}
}
}
38 changes: 38 additions & 0 deletions src/Application.Tests/Mocks/NoticeMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class NoticeMock
{
public static Notice MockValidNotice() => new(
registrationStartDate: DateTime.UtcNow,
registrationEndDate: DateTime.UtcNow.AddDays(7),
evaluationStartDate: DateTime.UtcNow.AddDays(8),
evaluationEndDate: DateTime.UtcNow.AddDays(14),
appealStartDate: DateTime.UtcNow.AddDays(15),
appealFinalDate: DateTime.UtcNow.AddDays(21),
sendingDocsStartDate: DateTime.UtcNow.AddDays(22),
sendingDocsEndDate: DateTime.UtcNow.AddDays(28),
partialReportDeadline: DateTime.UtcNow.AddDays(29),
finalReportDeadline: DateTime.UtcNow.AddDays(35),
description: "Edital de teste",
suspensionYears: 1
);

public static Notice MockValidNoticeWithId() => new(
id: Guid.NewGuid(),
registrationStartDate: DateTime.UtcNow,
registrationEndDate: DateTime.UtcNow.AddDays(7),
evaluationStartDate: DateTime.UtcNow.AddDays(8),
evaluationEndDate: DateTime.UtcNow.AddDays(14),
appealStartDate: DateTime.UtcNow.AddDays(15),
appealFinalDate: DateTime.UtcNow.AddDays(21),
sendingDocsStartDate: DateTime.UtcNow.AddDays(22),
sendingDocsEndDate: DateTime.UtcNow.AddDays(28),
partialReportDeadline: DateTime.UtcNow.AddDays(29),
finalReportDeadline: DateTime.UtcNow.AddDays(35),
description: "Edital de teste",
suspensionYears: 1
);
}
}
9 changes: 9 additions & 0 deletions src/Application.Tests/Mocks/ProgramTypeMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class ProgramTypeMock
{
public static ProgramType MockValidProgramType() => new("Program Name", "Program Description");
}
}
9 changes: 9 additions & 0 deletions src/Application.Tests/Mocks/ProjectActivityMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class ProjectActivityMock
{
public static ProjectActivity MockValidProjectActivity() => new(Guid.NewGuid(), Guid.NewGuid(), 5, 3);
}
}
23 changes: 23 additions & 0 deletions src/Application.Tests/Mocks/ProjectEvaluationMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Domain.Entities;
using Domain.Entities.Enums;

namespace Application.Tests.Mocks
{
public static class ProjectEvaluationMock
{
public static ProjectEvaluation MockValidProjectEvaluation() =>
new(
Guid.NewGuid(),
true,
Guid.NewGuid(),
EProjectStatus.Accepted,
DateTime.UtcNow,
"Valid Submission Evaluation Description",
EQualification.Doctor,
EScore.Excellent,
EScore.Excellent,
EScore.Excellent,
EScore.Excellent,
10.0);
}
}
25 changes: 25 additions & 0 deletions src/Application.Tests/Mocks/ProjectFinalReportMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class ProjectFinalReportMock
{
public static ProjectFinalReport MockValidProjectFinalReport()
{
return new ProjectFinalReport(Guid.NewGuid(), Guid.NewGuid())
{
ReportUrl = "https://example.com/report",
SendDate = DateTime.UtcNow
};
}

public static ProjectFinalReport MockValidProjectFinalReportWithId()
{
return new ProjectFinalReport(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid())
{
ReportUrl = "https://example.com/report",
SendDate = DateTime.UtcNow
};
}
}
}
105 changes: 105 additions & 0 deletions src/Application.Tests/Mocks/ProjectMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Domain.Entities;
using Domain.Entities.Enums;

namespace Application.Tests.Mocks
{
public static class ProjectMock
{
public static Project MockValidProject() => new(
"Project Title",
"Keyword 1",
"Keyword 2",
"Keyword 3",
true,
"Objective",
"Methodology",
"Expected Results",
"Schedule",
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
EProjectStatus.Opened,
"Status Description",
"Appeal Observation",
DateTime.UtcNow,
DateTime.UtcNow,
DateTime.UtcNow,
"Cancellation Reason");

public static Project MockValidProjectWithId() => new(
Guid.NewGuid(),
"Project Title",
"Keyword 1",
"Keyword 2",
"Keyword 3",
true,
"Objective",
"Methodology",
"Expected Results",
"Schedule",
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
EProjectStatus.Opened,
"Status Description",
"Appeal Observation",
DateTime.UtcNow,
DateTime.UtcNow,
DateTime.UtcNow,
"Cancellation Reason");

public static Project MockValidProjectProfessorAndNotice()
{
return new(
Guid.NewGuid(),
"Project Title",
"Keyword 1",
"Keyword 2",
"Keyword 3",
true,
"Objective",
"Methodology",
"Expected Results",
"Schedule",
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
EProjectStatus.Opened,
"Status Description",
"Appeal Observation",
DateTime.UtcNow,
DateTime.UtcNow,
DateTime.UtcNow,
"Cancellation Reason")
{
SubArea = new SubArea(Guid.NewGuid(), "SubArea Name", "SubArea Code"),
ProgramType = new ProgramType("Program Type Name", "Program Type Description"),
Professor = new Professor("1234567", 1234567)
{
User = new User("Name", "[email protected]", "Password", "58411338029", ERole.ADMIN)
},
Notice = new(
id: Guid.NewGuid(),
registrationStartDate: DateTime.UtcNow,
registrationEndDate: DateTime.UtcNow.AddDays(7),
evaluationStartDate: DateTime.UtcNow.AddDays(8),
evaluationEndDate: DateTime.UtcNow.AddDays(14),
appealStartDate: DateTime.UtcNow.AddDays(15),
appealFinalDate: DateTime.UtcNow.AddDays(21),
sendingDocsStartDate: DateTime.UtcNow.AddDays(22),
sendingDocsEndDate: DateTime.UtcNow.AddDays(28),
partialReportDeadline: DateTime.UtcNow.AddDays(29),
finalReportDeadline: DateTime.UtcNow.AddDays(35),
description: "Edital de teste",
suspensionYears: 1
)
};
}
}
}
17 changes: 17 additions & 0 deletions src/Application.Tests/Mocks/ProjectPartialReportMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Domain.Entities.Enums;

namespace Application.Tests.Mocks
{
public class ProjectPartialReportMock
{
public static Domain.Entities.ProjectPartialReport MockValidProjectPartialReport()
{
return new Domain.Entities.ProjectPartialReport(
projectId: Guid.NewGuid(),
currentDevelopmentStage: 1,
scholarPerformance: EScholarPerformance.Good,
additionalInfo: "Additional Information",
userId: Guid.NewGuid());
}
}
}
52 changes: 52 additions & 0 deletions src/Application.Tests/Mocks/StudentMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Domain.Entities.Enums;

namespace Application.Tests.Mocks
{
public static class StudentMock
{
public static Domain.Entities.Student MockValidStudent() => new(
birthDate: new DateTime(2000, 1, 1),
rg: 123456789,
issuingAgency: "Agency",
dispatchDate: new DateTime(2020, 1, 1),
gender: EGender.M,
race: ERace.White,
homeAddress: "Street 1",
city: "City",
uf: "UF",
cep: 12345678,
phoneDDD: 11,
phone: 12345678,
cellPhoneDDD: 22,
cellPhone: 987654321,
campusId: Guid.NewGuid(),
courseId: Guid.NewGuid(),
startYear: "2022",
studentAssistanceProgramId: Guid.NewGuid(),
registrationCode: "GCOM1234567"
);

public static Domain.Entities.Student MockValidStudentWithId() => new(
id: Guid.NewGuid(),
birthDate: new DateTime(2000, 1, 1),
rg: 123456789,
issuingAgency: "Agency",
dispatchDate: new DateTime(2020, 1, 1),
gender: EGender.M,
race: ERace.White,
homeAddress: "Street 1",
city: "City",
uf: "UF",
cep: 12345678,
phoneDDD: 11,
phone: 12345678,
cellPhoneDDD: 22,
cellPhone: 987654321,
campusId: Guid.NewGuid(),
courseId: Guid.NewGuid(),
startYear: "2022",
studentAssistanceProgramId: Guid.NewGuid(),
registrationCode: "GCOM1234567"
);
}
}
9 changes: 9 additions & 0 deletions src/Application.Tests/Mocks/SubAreaMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Domain.Entities;

namespace Application.Tests.Mocks
{
public static class SubAreaMock
{
public static SubArea MockValidSubArea() => new(Guid.NewGuid(), "ABC", "SubArea Name");
}
}
10 changes: 10 additions & 0 deletions src/Application.Tests/Mocks/UserMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Domain.Entities.Enums;

namespace Application.Tests.Mocks
{
public static class UserMock
{
public static Domain.Entities.User MockValidUser() => new(Guid.NewGuid(), "John Doe", "[email protected]", "strongpassword", "92114660087", ERole.ADMIN);

}
}
Binary file added src/Application.Tests/Samples/sample.pdf
Binary file not shown.
Loading

0 comments on commit a6a2296

Please sign in to comment.