Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.2" />
<PackageReference Include="Aspire.Hosting.Redis" Version="9.5.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GeneratorService\GeneratorService.csproj" />
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var builder = DistributedApplication.CreateBuilder(args);

var redis = builder.AddRedis("redis")
.WithRedisInsight();

var client = builder.AddProject<Projects.Client_Wasm>("client");

builder.AddProject<Projects.GeneratorService>("generator-service")
.WithReference(redis)
.WaitFor(redis)
.WithEnvironment("Cors__AllowedOrigin", client.GetEndpoint("http"))
.WaitFor(client)
.WithUrlForEndpoint("http", url => url.Url += "/swagger")
.WithUrlForEndpoint("https", url => url.Url += "/swagger");

builder.Build().Run();
16 changes: 16 additions & 0 deletions AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"profiles": {
"AppHost": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17193;http://localhost:15237",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21193",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22057"
}
}
}
}
8 changes: 4 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</CardHeader>
<CardBody>
<UnorderedList Unstyled>
<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
<UnorderedListItem>Номер <Strong>№ 1</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№ 18</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Чумаковым Иваном 6511</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/mestromezer/cloud-development/tree/main/">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
6 changes: 3 additions & 3 deletions Client.Wasm/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5127",
"environmentVariables": {
Expand All @@ -22,7 +22,7 @@
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7282;http://localhost:5127",
"environmentVariables": {
Expand All @@ -31,7 +31,7 @@
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
9 changes: 1 addition & 8 deletions Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"BaseAddress": ""
"BaseAddress": "http://localhost:3343/patient"
}
24 changes: 24 additions & 0 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "AppHost\AppHost.csproj", "{B1C2D3E4-F5A6-7890-ABCD-EF1234567890}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneratorService", "GeneratorService\GeneratorService.csproj", "{139BD442-54A6-9109-CF9A-53DA218D46F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneratorService.Tests", "GeneratorService.Tests\GeneratorService.Tests.csproj", "{EBCA1829-1CB1-773B-8241-CE00EBFBCF9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "ServiceDefaults\ServiceDefaults.csproj", "{9F0B1437-6E39-4706-8A9D-89BCE4B31AA0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +23,22 @@ Global
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{B1C2D3E4-F5A6-7890-ABCD-EF1234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1C2D3E4-F5A6-7890-ABCD-EF1234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1C2D3E4-F5A6-7890-ABCD-EF1234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1C2D3E4-F5A6-7890-ABCD-EF1234567890}.Release|Any CPU.Build.0 = Release|Any CPU
{139BD442-54A6-9109-CF9A-53DA218D46F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{139BD442-54A6-9109-CF9A-53DA218D46F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{139BD442-54A6-9109-CF9A-53DA218D46F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{139BD442-54A6-9109-CF9A-53DA218D46F2}.Release|Any CPU.Build.0 = Release|Any CPU
{EBCA1829-1CB1-773B-8241-CE00EBFBCF9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBCA1829-1CB1-773B-8241-CE00EBFBCF9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBCA1829-1CB1-773B-8241-CE00EBFBCF9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBCA1829-1CB1-773B-8241-CE00EBFBCF9C}.Release|Any CPU.Build.0 = Release|Any CPU
{9F0B1437-6E39-4706-8A9D-89BCE4B31AA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F0B1437-6E39-4706-8A9D-89BCE4B31AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F0B1437-6E39-4706-8A9D-89BCE4B31AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F0B1437-6E39-4706-8A9D-89BCE4B31AA0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 23 additions & 0 deletions GeneratorService.Tests/GeneratorService.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GeneratorService\GeneratorService.csproj" />
</ItemGroup>

</Project>
62 changes: 62 additions & 0 deletions GeneratorService.Tests/MedicalPatientGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using GeneratorService.Generators;
using Xunit;

namespace GeneratorService.Tests;

public sealed class MedicalPatientGeneratorTests
{
public static readonly DateOnly Today = DateOnly.FromDateTime(DateTime.Today);

public static IEnumerable<object[]> Patients() =>
Enumerable.Range(1, 300).Select(i => new object[] { MedicalPatientGenerator.Generate(i) });

[Theory]
[MemberData(nameof(Patients))]
public void Id_MatchesRequested(GeneratorService.Models.MedicalPatient p)
=> Assert.True(p.Id > 0);

[Theory]
[MemberData(nameof(Patients))]
public void FullName_HasThreeParts(GeneratorService.Models.MedicalPatient p)
=> Assert.Equal(3, p.FullName.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length);

[Theory]
[MemberData(nameof(Patients))]
public void BirthDate_NotInFuture(GeneratorService.Models.MedicalPatient p)
=> Assert.True(p.BirthDate <= Today);

[Theory]
[MemberData(nameof(Patients))]
public void Height_InReasonableBounds(GeneratorService.Models.MedicalPatient p)
=> Assert.InRange(p.Height, 50.0, 220.0);

[Theory]
[MemberData(nameof(Patients))]
public void Height_RoundedToTwoDecimals(GeneratorService.Models.MedicalPatient p)
=> Assert.Equal(p.Height, Math.Round(p.Height, 2));

[Theory]
[MemberData(nameof(Patients))]
public void Weight_InReasonableBounds(GeneratorService.Models.MedicalPatient p)
=> Assert.InRange(p.Weight, 2.5, 200.0);

[Theory]
[MemberData(nameof(Patients))]
public void Weight_RoundedToTwoDecimals(GeneratorService.Models.MedicalPatient p)
=> Assert.Equal(p.Weight, Math.Round(p.Weight, 2));

[Theory]
[MemberData(nameof(Patients))]
public void BloodGroup_Between1And4(GeneratorService.Models.MedicalPatient p)
=> Assert.InRange(p.BloodGroup, 1, 4);

[Theory]
[MemberData(nameof(Patients))]
public void LastExamination_NotBeforeBirthDate(GeneratorService.Models.MedicalPatient p)
=> Assert.True(p.LastExaminationDate >= p.BirthDate);

[Theory]
[MemberData(nameof(Patients))]
public void LastExamination_NotInFuture(GeneratorService.Models.MedicalPatient p)
=> Assert.True(p.LastExaminationDate <= Today);
}
24 changes: 24 additions & 0 deletions GeneratorService/GeneratorService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.2.2" />
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions GeneratorService/Generators/MedicalPatientGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Bogus;
using GeneratorService.Models;

namespace GeneratorService.Generators;

public static class MedicalPatientGenerator
{
private static readonly Faker<MedicalPatient> _faker = new Faker<MedicalPatient>("ru")
.RuleFor(p => p.Id, _ => 0)
.RuleFor(p => p.FullName, f =>
$"{f.Name.LastName()} {f.Name.FirstName()} {f.Name.LastName()}ович")
.RuleFor(p => p.Address, f => f.Address.FullAddress())
.RuleFor(p => p.BirthDate, f => f.Date.PastDateOnly(100))
.RuleFor(p => p.Height, f => Math.Round(f.Random.Double(50.0, 220.0), 2))
.RuleFor(p => p.Weight, f => Math.Round(f.Random.Double(2.5, 200.0), 2))
.RuleFor(p => p.BloodGroup, f => f.Random.Int(1, 4))
.RuleFor(p => p.RhFactor, f => f.Random.Bool())
.RuleFor(p => p.LastExaminationDate, (f, p) =>
f.Date.BetweenDateOnly(p.BirthDate, DateOnly.FromDateTime(DateTime.Today)))
.RuleFor(p => p.IsVaccinated, f => f.Random.Bool());

public static MedicalPatient Generate(int id)
{
var generated = _faker.Generate();
return new MedicalPatient
{
Id = id,
FullName = generated.FullName,
Address = generated.Address,
BirthDate = generated.BirthDate,
Height = generated.Height,
Weight = generated.Weight,
BloodGroup = generated.BloodGroup,
RhFactor = generated.RhFactor,
LastExaminationDate = generated.LastExaminationDate,
IsVaccinated = generated.IsVaccinated
};
}
}
37 changes: 37 additions & 0 deletions GeneratorService/Models/MedicalPatient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace GeneratorService.Models;

/// <summary>
/// Медицинская карта пациента.
/// </summary>
public sealed class MedicalPatient
{
/// <summary>Уникальный идентификатор пациента.</summary>
public int Id { get; init; }

/// <summary>Полное имя пациента (фамилия, имя, отчество).</summary>
public required string FullName { get; init; }

/// <summary>Адрес проживания пациента.</summary>
public required string Address { get; init; }

/// <summary>Дата рождения пациента.</summary>
public DateOnly BirthDate { get; init; }

/// <summary>Рост пациента в сантиметрах.</summary>
public double Height { get; init; }

/// <summary>Вес пациента в килограммах.</summary>
public double Weight { get; init; }

/// <summary>Группа крови (1–4).</summary>
public int BloodGroup { get; init; }

/// <summary>Резус-фактор: <c>true</c> — положительный, <c>false</c> — отрицательный.</summary>
public bool RhFactor { get; init; }

/// <summary>Дата последнего медицинского осмотра.</summary>
public DateOnly LastExaminationDate { get; init; }

/// <summary>Наличие прививок.</summary>
public bool IsVaccinated { get; init; }
}
Loading