Skip to content

Commit 6fc3d20

Browse files
author
sam.gerene
committed
[Add] project details page; fixes #10
[Add] viewer test project
1 parent 9c9d875 commit 6fc3d20

File tree

15 files changed

+596
-9
lines changed

15 files changed

+596
-9
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="CommitHistoryServiceTestFixture.cs" company="RHEA System S.A.">
3+
//
4+
// Copyright 2022 RHEA System S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
namespace SysML2.NET.Viewer.Tests.Services.CommitHistory
22+
{
23+
using System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
27+
using NUnit.Framework;
28+
29+
using SysML2.NET.API.DTO;
30+
31+
using SysML2.NET.Viewer.Services.CommitHistory;
32+
33+
/// <summary>
34+
/// Suite of tests for the <see cref="CommitHistoryService"/>
35+
/// </summary>
36+
[TestFixture]
37+
public class CommitHistoryServiceTestFixture
38+
{
39+
private CommitHistoryService commitHistoryService;
40+
41+
private Branch branch;
42+
43+
private List<Commit> commits;
44+
45+
[SetUp]
46+
public void SetUp()
47+
{
48+
this.commitHistoryService = new CommitHistoryService();
49+
50+
this.CreateTestData();
51+
}
52+
53+
private void CreateTestData()
54+
{
55+
var projectId = Guid.NewGuid();
56+
57+
var head = new Commit
58+
{
59+
Id = Guid.NewGuid(),
60+
OwningProject = projectId,
61+
Description = "5"
62+
};
63+
64+
65+
var commit_1 = new Commit
66+
{
67+
Id = Guid.NewGuid(),
68+
OwningProject = projectId,
69+
Description = "1"
70+
};
71+
72+
var commit_2 = new Commit
73+
{
74+
Id = Guid.NewGuid(),
75+
OwningProject = projectId,
76+
Description = "2"
77+
};
78+
79+
var commit_3 = new Commit
80+
{
81+
Id = Guid.NewGuid(),
82+
OwningProject = projectId,
83+
Description = "3"
84+
};
85+
86+
var commit_4 = new Commit
87+
{
88+
Id = Guid.NewGuid(),
89+
OwningProject = projectId,
90+
Description = "4"
91+
};
92+
93+
this.branch = new Branch
94+
{
95+
Id = Guid.NewGuid(),
96+
Head = head.Id,
97+
};
98+
99+
head.PreviousCommit = commit_4.Id;
100+
commit_4.PreviousCommit = commit_3.Id;
101+
commit_3.PreviousCommit = commit_2.Id;
102+
commit_2.PreviousCommit = commit_1.Id;
103+
104+
this.commits = new List<Commit>();
105+
this.commits.Add(commit_2);
106+
this.commits.Add(commit_4);
107+
this.commits.Add(commit_1);
108+
this.commits.Add(head);
109+
this.commits.Add(commit_3);
110+
this.commits.Add(new Commit() {Id = Guid.NewGuid()});
111+
this.commits.Add(new Commit() { Id = Guid.NewGuid() });
112+
}
113+
114+
[Test]
115+
public void Verify_that_expected_commit_history_is_returned()
116+
{
117+
var history = this.commitHistoryService.QueryCommitHistory(this.branch, this.commits);
118+
119+
Assert.That(history.Count(), Is.EqualTo(5));
120+
121+
Assert.That(history[0].Description, Is.EqualTo("5"));
122+
Assert.That(history[1].Description, Is.EqualTo("4"));
123+
Assert.That(history[2].Description, Is.EqualTo("3"));
124+
Assert.That(history[3].Description, Is.EqualTo("2"));
125+
Assert.That(history[4].Description, Is.EqualTo("1"));
126+
}
127+
}
128+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Company>RHEA System S.A.</Company>
6+
<Authors>Sam Gerene</Authors>
7+
<Description>Nunit test suite for the SysML2.NET.Viewer project</Description>
8+
<Copyright>Copyright 2022 RHEA System S.A.</Copyright>
9+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
10+
<RepositoryUrl>https://github.com/RHEAGROUP/SysML2.NET.git</RepositoryUrl>
11+
<RepositoryType>Git</RepositoryType>
12+
<ImplicitUsings>false</ImplicitUsings>
13+
<Nullable>disable</Nullable>
14+
<IsPackable>false</IsPackable>
15+
<PreserveCompilationContext>true</PreserveCompilationContext>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
21+
<PackageReference Include="NUnit" Version="3.13.3" />
22+
<PackageReference Include="NUnit.Console" Version="3.15.2" />
23+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
24+
25+
<PackageReference Include="coverlet.collector" Version="3.1.2">
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
<PrivateAssets>all</PrivateAssets>
28+
</PackageReference>
29+
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
30+
<PrivateAssets>all</PrivateAssets>
31+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32+
</PackageReference>
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<Folder Include="Services\" />
37+
</ItemGroup>
38+
39+
</Project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Company>RHEA System S.A.</Company>
6+
<Authors>Sam Gerene</Authors>
7+
<Description>Nunit test suite for the SysML2.NET.Viewer project</Description>
8+
<Copyright>Copyright 2022 RHEA System S.A.</Copyright>
9+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
10+
<RepositoryUrl>https://github.com/RHEAGROUP/SysML2.NET.git</RepositoryUrl>
11+
<RepositoryType>Git</RepositoryType>
12+
<ImplicitUsings>false</ImplicitUsings>
13+
<Nullable>disable</Nullable>
14+
<IsPackable>false</IsPackable>
15+
<PreserveCompilationContext>true</PreserveCompilationContext>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
21+
<PackageReference Include="NUnit" Version="3.13.3" />
22+
<PackageReference Include="NUnit.Console" Version="3.15.2" />
23+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
24+
25+
<PackageReference Include="coverlet.collector" Version="3.1.2">
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
<PrivateAssets>all</PrivateAssets>
28+
</PackageReference>
29+
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
30+
<PrivateAssets>all</PrivateAssets>
31+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32+
</PackageReference>
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<Folder Include="Services\CommitHistory\" />
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<ProjectReference Include="..\SysML2.NET.Viewer\SysML2.NET.Viewer.csproj" />
41+
</ItemGroup>
42+
43+
</Project>

SysML2.NET.Viewer/Pages/ProjectDetails.razor

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ limitations under the License.
1616

1717
@page "/projects/{Id}"
1818

19+
@using SysML2.NET.API.DTO
20+
@using System.Globalization
21+
1922
@if (isLoading)
2023
{
2124
<RadzenHeading Size="H1" style="display: inline-block" Text="Project Details"></RadzenHeading>
@@ -24,5 +27,96 @@ limitations under the License.
2427
}
2528
else
2629
{
27-
<RadzenHeading Size="H1" style="display: inline-block" Text="Project Details"></RadzenHeading>
30+
<RadzenFieldset AllowCollapse="true" Style="margin-bottom: 10px;">
31+
<HeaderTemplate>
32+
<span class="d-inline-flex align-items-center align-middle">
33+
<RadzenIcon Icon="stars" Class="mr-1" /><b>Project Details</b>
34+
</span>
35+
</HeaderTemplate>
36+
37+
<ChildContent>
38+
<div class="row">
39+
<div class="col-md-6 col-xl-6 col-lg-6">
40+
<div><b>Name:</b></div>
41+
<div>@(string.IsNullOrEmpty(this.project?.Name) ? "NOT SET" : this.project.Name) </div>
42+
43+
<div><b>Default Branch:</b></div>
44+
<div>@(this.defaultBranch == null ? "NOT SET" : this.defaultBranch.Name)</div>
45+
46+
<div><b>Branches: </b>@(this.branches == null ? "0" : this.branches.Count())</div>
47+
48+
<div><b>Tags: </b>@(this.tags == null ? "0" : this.tags.Count())</div>
49+
</div>
50+
51+
<div class="col-md-6 col-xl-6 col-lg-6">
52+
<div><b>Description:</b></div>
53+
<div>@(string.IsNullOrEmpty(this.project?.Description) ? "NOT SET" : this.project.Description) </div>
54+
</div>
55+
</div>
56+
</ChildContent>
57+
</RadzenFieldset>
58+
59+
<RadzenDataGrid Count="@this.branches.Count()" AllowFiltering="true" AllowColumnResize="true" Data="@this.branches" TItem="Branch" Style="margin-bottom: 10px;">
60+
<Columns>
61+
<RadzenDataGridColumn TItem="Branch" Title="Name">
62+
<Template Context="branch">
63+
<span>
64+
<RadzenIcon Icon="alt_route"/>
65+
<a href="/projects/@project?.Id">@branch.Name</a>
66+
@if (branch.Id == this.defaultBranch.Id)
67+
{
68+
<BSBadge Style="margin-left: 5px" Color="BSColor.Primary" IsPill="true">default</BSBadge>
69+
}
70+
</span>
71+
</Template>
72+
</RadzenDataGridColumn>
73+
<RadzenDataGridColumn TItem="Branch" Property="Description" Title="Description" />
74+
<RadzenDataGridColumn TItem="Branch" Title="Head">
75+
<Template Context="branch">
76+
@branch.Head
77+
</Template>
78+
</RadzenDataGridColumn>
79+
<RadzenDataGridColumn TItem="Branch" Title="TimeStamp">
80+
<Template Context="branch">
81+
@branch.TimeStamp.ToString("yyyy-MM-dd, HH:mm:ss", CultureInfo.InvariantCulture)
82+
</Template>
83+
</RadzenDataGridColumn>
84+
</Columns>
85+
</RadzenDataGrid>
86+
87+
<RadzenDropDown @bind-Value="this.selectedBranchId" TValue="Guid"
88+
Multiple="false" Placeholder="Select Branch..."
89+
Data="@this.branches" TextProperty="Name" ValueProperty="Id"
90+
Change="@this.BranchSelectionChange">
91+
</RadzenDropDown>
92+
93+
<RadzenDataGrid Count="@this.commits.Count()" AllowSorting="true" AllowColumnResize="true" Data="@this.commitHistory" TItem="Commit">
94+
<Columns>
95+
<RadzenDataGridColumn TItem="Commit" Title="Identifier">
96+
<Template Context="commit">
97+
<span>
98+
<div>@commit.Id</div>
99+
@foreach (var tag in this.tags)
100+
{
101+
if (@tag.TaggedCommit == @commit.Id)
102+
{
103+
<BSBadge Style="margin-left: 5px" Color="BSColor.Info" IsPill="true">@tag.Name</BSBadge>
104+
}
105+
}
106+
</span>
107+
</Template>
108+
</RadzenDataGridColumn>
109+
<RadzenDataGridColumn TItem="Commit" Property="Description" Title="Description" />
110+
<RadzenDataGridColumn TItem="Commit" Title="Previous Commit">
111+
<Template Context="commit">
112+
@commit.PreviousCommit
113+
</Template>
114+
</RadzenDataGridColumn>
115+
<RadzenDataGridColumn TItem="Commit" Title="TimeStamp">
116+
<Template Context="commit">
117+
@commit.TimeStamp.ToString("yyyy-MM-dd, HH:mm:ss", CultureInfo.InvariantCulture)
118+
</Template>
119+
</RadzenDataGridColumn>
120+
</Columns>
121+
</RadzenDataGrid>
28122
}

0 commit comments

Comments
 (0)