Skip to content
Open
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
25 changes: 25 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
22 changes: 22 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyNUnitWeb", "MyNUnitWeb\MyNUnitWeb.csproj", "{3FEAAE92-D751-4E3D-9981-F689E9356C25}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyNUnit", "..\..\5Homework23.11.22\MyNUnit\MyNUnit\MyNUnit.csproj", "{E2F7FBFB-7BCE-4825-B0AA-DF4651B9C9C7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FEAAE92-D751-4E3D-9981-F689E9356C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FEAAE92-D751-4E3D-9981-F689E9356C25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FEAAE92-D751-4E3D-9981-F689E9356C25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FEAAE92-D751-4E3D-9981-F689E9356C25}.Release|Any CPU.Build.0 = Release|Any CPU
{E2F7FBFB-7BCE-4825-B0AA-DF4651B9C9C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2F7FBFB-7BCE-4825-B0AA-DF4651B9C9C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2F7FBFB-7BCE-4825-B0AA-DF4651B9C9C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2F7FBFB-7BCE-4825-B0AA-DF4651B9C9C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Data/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace MyNUnitWeb.Data;

using System.ComponentModel.DataAnnotations.Schema;

public class Assembly

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментариев глобально не хватает.

{
[Column("id_assembly")]
public int AssemblyId { get; set; }

[Column("name")]
public string Name { get; set; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullability-анализ недоволен происходящим, тут и ниже. Если эти данные могут приходить извне, возможно, стоило поля явно nullable сделать.


[Column("test_count")]
public int TestsCount { get; set; }

[Column("passed")]
public int Passed { get; set; }

[Column("failed")]
public int Failed { get; set; }

[Column("ignored")]
public int Ignored { get; set; }

[Column("datetime")]
public string? Datetime { get; set; }

public virtual ICollection<Test> Tests { get; set; }
}
29 changes: 29 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Data/Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace MyNUnitWeb.Data;

using System.ComponentModel.DataAnnotations.Schema;

public class Test
{
[Column("id_test")]
public int TestId { get; set; }

[Column("id_assembly")]
public int AssemblyId { get; set; }

[Column("name")]
public string Name { get; set; }

[Column("is_passed")]
public bool IsPassed { get; set; }

[Column("running_time")]
public int RunningTime { get; set; }

[Column("reason_for_ignoring")]
public string? ReasonForIgnoring { get; set; }

[Column("comment")]
public string? Comment { get; set; }

public virtual Assembly Assembly { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace MyNUnitWeb.Data;

using Microsoft.EntityFrameworkCore;

public class TestingDataDbContext : DbContext
{
public TestingDataDbContext(DbContextOptions<TestingDataDbContext> options)
: base(options)
{
}

public DbSet<Assembly> Assemblies { get; set; }

public DbSet<Test> Tests { get; set; }
}
35 changes: 35 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Data/database-scripts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--/*
CREATE TABLE assembly (
name TEXT NOT NULL,
tests_count INT NOT NULL,
passed INT NOT NULL,
failed INT NOT NULL,
ignored INT NOT NULL,
datetime TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
--*/

--/*
CREATE TABLE test (
id_assembly INT,
name TEXT NOT NULL,
is_passed INT NOT NULL,
running_time INT NOT NULL,
reason_for_ignoring TEXT,
comment TEXT,
FOREIGN KEY(id_assembly) REFERENCES assembly(ROWID)
);
--*/

INSERT INTO assembly (name, tests_count, passed, failed, ignored)
values ('assembly_name1', 3, 1, 1, 1);

INSERT INTO test (id_assembly, name, is_passed, running_time, reason_for_ignoring, comment)
values (1, 'test_name3', FALSE, 0, 'Ignored.', '');

SELECT * FROM assembly;
SELECT * FROM assembly WHERE ROWID = 1;
SELECT * FROM test;

DROP TABLE assembly;
DROP TABLE test;
Empty file.
20 changes: 20 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["MyNUnitWeb/MyNUnitWeb.csproj", "MyNUnitWeb/"]
RUN dotnet restore "MyNUnitWeb/MyNUnitWeb.csproj"
COPY . .
WORKDIR "/src/MyNUnitWeb"
RUN dotnet build "MyNUnitWeb.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyNUnitWeb.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyNUnitWeb.dll"]
26 changes: 26 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/MyNUnitWeb.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.1.23111.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.0-preview.1.23111.4" />
<PackageReference Include="SQLite" Version="3.13.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\5Homework23.11.22\MyNUnit\MyNUnit\MyNUnit.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/About.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@page
@model MyNUnitWeb.Pages.About

@{
ViewData["Title"] = "About";
}

<div>
<a href="https://github.com/Niksen111/spbuHomeworksSem3/tree/main/5Homework23.11.22/MyNUnit" class="link-primary">MyNUnit github</a>
</div>
11 changes: 11 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/About.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace MyNUnitWeb.Pages;

public class About : PageModel
{
public void OnGet()
{

}
}
29 changes: 29 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/Assembly.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@page "{assmeblyId}"
@model MyNUnitWeb.Pages.Assembly

@{
ViewData["Title"] = "Assembly";
}

<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Test name</th>
<th>Is passed</th>
<th>Running time</th>
<th>Reason for ignoring</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
@foreach (Data.Test t in Model.Tests) {
<tr>
<td>@t.Name</td>
<td>@(t.IsPassed ? "Yes" : "No")</td>
<td>@t.RunningTime</td>
<td>@t.ReasonForIgnoring</td>
<td>@t.Comment</td>
</tr>
}
</tbody>
</table>
19 changes: 19 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/Assembly.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using MyNUnitWeb.Data;

namespace MyNUnitWeb.Pages;

public class Assembly : PageModel
{
private readonly TestingDataDbContext context;

public Assembly(TestingDataDbContext context)
=> this.context = context;

public IList<Test> Tests { get; private set; } = new List<Test>();

public void OnGet(int assemblyId)
{
Tests = context.Tests.Where(t => t.AssemblyId == assemblyId).Select(t => t).ToList();
}
}
26 changes: 26 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
26 changes: 26 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace MyNUnitWeb.Pages;

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
30 changes: 30 additions & 0 deletions 6Homework7.12.22/MyNUnitWeb/MyNUnitWeb/Pages/History.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@page
@model MyNUnitWeb.Pages.History

@{
ViewData["Title"] = "History";
}

<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Assembly name</th>
<th>Tests count</th>
<th>Passed</th>
<th>Failed</th>
<th>Ignored</th>
<th>Date and Time</th>
</tr>
</thead>
<tbody>
@foreach (Data.Assembly t in Model.Assemblies) {
<tr>
<td>@t.Name</td>
<td>@t.Passed</td>
<td>@t.Failed</td>
<td>@t.Ignored</td>
<td>@t.Datetime</td>
</tr>
}
</tbody>
</table>
Loading