Skip to content

Commit eae5a28

Browse files
author
samatrhea
committed
[CleanUp] viewer source files
[Update] copyright statement
1 parent 7cb1d74 commit eae5a28

13 files changed

Lines changed: 424 additions & 422 deletions

File tree

SysML2.NET.Viewer.Tests/Services/Authentication/AuthenticationServiceTestFixture.cs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,75 +20,75 @@
2020

2121
namespace SysML2.NET.Viewer.Tests.Services.Authentication
2222
{
23-
using System;
24-
using System.Threading;
25-
using System.Threading.Tasks;
23+
using System;
24+
using System.Threading;
25+
using System.Threading.Tasks;
2626

27-
using Blazored.SessionStorage;
28-
29-
using Moq;
27+
using Blazored.SessionStorage;
28+
29+
using Moq;
3030

31-
using NUnit.Framework;
31+
using NUnit.Framework;
3232

33-
using SySML2.NET.REST;
34-
using SysML2.NET.Viewer.Services.Authentication;
33+
using SySML2.NET.REST;
34+
using SysML2.NET.Viewer.Services.Authentication;
3535

36-
/// <summary>
37-
/// Suite of tests for the <see cref="AuthenticationService"/>
38-
/// </summary>
39-
[TestFixture]
40-
public class AuthenticationServiceTestFixture
41-
{
42-
private Mock<ISessionStorageService> sessionStorageService;
36+
/// <summary>
37+
/// Suite of tests for the <see cref="AuthenticationService"/>
38+
/// </summary>
39+
[TestFixture]
40+
public class AuthenticationServiceTestFixture
41+
{
42+
private Mock<ISessionStorageService> sessionStorageService;
4343

44-
private Mock<IRestClient> restClient;
44+
private Mock<IRestClient> restClient;
4545

46-
private AnonymousAuthenticationStateProvider authenticationStateProvider;
46+
private AnonymousAuthenticationStateProvider authenticationStateProvider;
4747

48-
private AuthenticationService authenticationService;
48+
private AuthenticationService authenticationService;
4949

50-
[SetUp]
51-
public void SetUp()
52-
{
53-
this.sessionStorageService = new Mock<ISessionStorageService>();
54-
this.restClient = new Mock<IRestClient>();
55-
this.authenticationStateProvider = new AnonymousAuthenticationStateProvider(this.sessionStorageService.Object);
50+
[SetUp]
51+
public void SetUp()
52+
{
53+
this.sessionStorageService = new Mock<ISessionStorageService>();
54+
this.restClient = new Mock<IRestClient>();
55+
this.authenticationStateProvider = new AnonymousAuthenticationStateProvider(this.sessionStorageService.Object);
5656

57-
this.authenticationService = new AuthenticationService(this.restClient.Object, this.authenticationStateProvider,this.sessionStorageService.Object);
58-
}
57+
this.authenticationService = new AuthenticationService(this.restClient.Object, this.authenticationStateProvider,this.sessionStorageService.Object);
58+
}
5959

60-
[Test]
61-
public async Task Verify_that_when_server_returns_with_success_authentication_returns_success()
62-
{
63-
var cts = new CancellationTokenSource();
64-
65-
var result = await this.authenticationService.Login("John", "Doe", "http:www.rheagroup.com", cts.Token);
60+
[Test]
61+
public async Task Verify_that_when_server_returns_with_success_authentication_returns_success()
62+
{
63+
var cts = new CancellationTokenSource();
64+
65+
var result = await this.authenticationService.Login("John", "Doe", "http:www.rheagroup.com", cts.Token);
6666

67-
Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Success));
68-
}
67+
Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Success));
68+
}
6969

70-
[Test]
71-
public async Task Verify_that_when_server_returns_without_success_authentication_returns_success()
72-
{
73-
var cts = new CancellationTokenSource();
70+
[Test]
71+
public async Task Verify_that_when_server_returns_without_success_authentication_returns_success()
72+
{
73+
var cts = new CancellationTokenSource();
7474

75-
this.restClient.Setup(x =>
76-
x.Open(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
77-
.Throws<Exception>();
75+
this.restClient.Setup(x =>
76+
x.Open(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
77+
.Throws<Exception>();
7878

79-
var result = await this.authenticationService.Login("John", "Doe", "http:www.rheagroup.com", cts.Token);
79+
var result = await this.authenticationService.Login("John", "Doe", "http:www.rheagroup.com", cts.Token);
8080

81-
Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Fail));
82-
}
81+
Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Fail));
82+
}
8383

84-
[Test]
85-
public async Task Verify_that_when_logout_session_storage_is_called_to_remove_session_key()
86-
{
87-
var cts = new CancellationTokenSource();
84+
[Test]
85+
public async Task Verify_that_when_logout_session_storage_is_called_to_remove_session_key()
86+
{
87+
var cts = new CancellationTokenSource();
8888

89-
await this.authenticationService.Logout(cts.Token);
89+
await this.authenticationService.Logout(cts.Token);
9090

91-
this.sessionStorageService.Verify(x => x.RemoveItemAsync(AnonymousAuthenticationStateProvider.SessionStorageKey, cts.Token), Times.Once);
92-
}
93-
}
91+
this.sessionStorageService.Verify(x => x.RemoveItemAsync(AnonymousAuthenticationStateProvider.SessionStorageKey, cts.Token), Times.Once);
92+
}
93+
}
9494
}

SysML2.NET.Viewer.Tests/Services/CommitHistory/CommitHistoryServiceTestFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ namespace SysML2.NET.Viewer.Tests.Services.CommitHistory
2222
{
2323
using System;
2424
using System.Collections.Generic;
25-
25+
2626
using NUnit.Framework;
2727

2828
using SysML2.NET.PIM.DTO;
29-
29+
3030
using SysML2.NET.Viewer.Services.CommitHistory;
3131

3232
/// <summary>

SysML2.NET.Viewer.Tests/ViewModels/Components/LogoutViewModelTextFixture.cs

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,67 @@
2020

2121
namespace SysML2.NET.Viewer.Tests.ViewModels.Components
2222
{
23-
using System.Threading.Tasks;
23+
using System.Threading.Tasks;
2424

25-
using Blazored.SessionStorage;
25+
using Blazored.SessionStorage;
2626

27-
using Bunit;
28-
using TestContext = Bunit.TestContext;
27+
using Bunit;
28+
using Bunit.TestDoubles;
29+
30+
using TestContext = Bunit.TestContext;
2931

30-
using Moq;
32+
using Microsoft.Extensions.DependencyInjection;
3133

32-
using NUnit.Framework;
34+
using Moq;
3335

34-
using SySML2.NET.REST;
35-
using SysML2.NET.Viewer.Services.Authentication;
36-
using SysML2.NET.Viewer.ViewModels.Components;
37-
using Bunit.TestDoubles;
38-
using Microsoft.Extensions.DependencyInjection;
36+
using NUnit.Framework;
3937

40-
/// <summary>
41-
/// Suite of tests for the <see cref="LogoutViewModel"/>
42-
/// </summary>
43-
[TestFixture]
44-
public class LogoutViewModelTextFixture
45-
{
46-
private TestContext context;
38+
using SySML2.NET.REST;
39+
using SysML2.NET.Viewer.Services.Authentication;
40+
using SysML2.NET.Viewer.ViewModels.Components;
4741

48-
private FakeNavigationManager navigationManager;
42+
/// <summary>
43+
/// Suite of tests for the <see cref="LogoutViewModel"/>
44+
/// </summary>
45+
[TestFixture]
46+
public class LogoutViewModelTextFixture
47+
{
48+
private TestContext context;
4949

50-
private LogoutViewModel logoutViewModel;
50+
private FakeNavigationManager navigationManager;
5151

52-
private AuthenticationService authenticationService;
52+
private LogoutViewModel logoutViewModel;
5353

54-
private AnonymousAuthenticationStateProvider authenticationStateProvider;
54+
private AuthenticationService authenticationService;
5555

56-
private Mock<ISessionStorageService> sessionStorageService;
56+
private AnonymousAuthenticationStateProvider authenticationStateProvider;
5757

58-
private Mock<IRestClient> restClient;
59-
60-
[SetUp]
61-
public void SetUp()
62-
{
63-
this.context = new TestContext();
58+
private Mock<ISessionStorageService> sessionStorageService;
6459

65-
this.sessionStorageService = new Mock<ISessionStorageService>();
66-
this.restClient = new Mock<IRestClient>();
67-
this.authenticationStateProvider = new AnonymousAuthenticationStateProvider(this.sessionStorageService.Object);
68-
69-
this.authenticationService = new AuthenticationService(this.restClient.Object, this.authenticationStateProvider, this.sessionStorageService.Object);
60+
private Mock<IRestClient> restClient;
7061

71-
this.navigationManager = this.context.Services.GetRequiredService<FakeNavigationManager>();
62+
[SetUp]
63+
public void SetUp()
64+
{
65+
this.context = new TestContext();
7266

73-
this.logoutViewModel = new LogoutViewModel(this.authenticationService, this.navigationManager);
74-
}
75-
76-
[Test]
77-
public async Task Verify_that_logout_works_as_expected()
78-
{
79-
await this.logoutViewModel.ExecuteLogout();
67+
this.sessionStorageService = new Mock<ISessionStorageService>();
68+
this.restClient = new Mock<IRestClient>();
69+
this.authenticationStateProvider = new AnonymousAuthenticationStateProvider(this.sessionStorageService.Object);
70+
71+
this.authenticationService = new AuthenticationService(this.restClient.Object, this.authenticationStateProvider, this.sessionStorageService.Object);
8072

81-
Assert.That(this.navigationManager.Uri, Is.EqualTo("http://localhost/"));
82-
}
83-
}
73+
this.navigationManager = this.context.Services.GetRequiredService<FakeNavigationManager>();
74+
75+
this.logoutViewModel = new LogoutViewModel(this.authenticationService, this.navigationManager);
76+
}
77+
78+
[Test]
79+
public async Task Verify_that_logout_works_as_expected()
80+
{
81+
await this.logoutViewModel.ExecuteLogout();
82+
83+
Assert.That(this.navigationManager.Uri, Is.EqualTo("http://localhost/"));
84+
}
85+
}
8486
}

SysML2.NET.Viewer/App.razor

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ limitations under the License.
1515
------------------------------------------------------------------------------->
1616

1717
<CascadingAuthenticationState>
18-
<Router AppAssembly="@typeof(App).Assembly" PreferExactMatches="@true">
19-
<Found Context="routeData">
20-
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
21-
<Authorizing>
22-
<text>Please wait, we are authorizing the user.</text>
23-
</Authorizing>
24-
<NotAuthorized>
25-
<text> You are not authorized to access this page. </text>
26-
</NotAuthorized>
27-
</AuthorizeRouteView>
28-
</Found>
29-
<NotFound>
30-
<PageTitle>Not found</PageTitle>
31-
<LayoutView Layout="@typeof(MainLayout)">
32-
<p>Sorry, there's nothing at this address.</p>
33-
</LayoutView>
34-
</NotFound>
35-
</Router>
18+
<Router AppAssembly="@typeof(App).Assembly" PreferExactMatches="@true">
19+
<Found Context="routeData">
20+
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
21+
<Authorizing>
22+
<text>Please wait, we are authorizing the user.</text>
23+
</Authorizing>
24+
<NotAuthorized>
25+
<text> You are not authorized to access this page. </text>
26+
</NotAuthorized>
27+
</AuthorizeRouteView>
28+
</Found>
29+
<NotFound>
30+
<PageTitle>Not found</PageTitle>
31+
<LayoutView Layout="@typeof(MainLayout)">
32+
<p>Sorry, there's nothing at this address.</p>
33+
</LayoutView>
34+
</NotFound>
35+
</Router>
3636
</CascadingAuthenticationState>

SysML2.NET.Viewer/Components/AboutComponent.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ limitations under the License.
5454

5555
<div class="row">
5656
<div class="col-md-12 text-center">
57-
<p>Copyright &copy; <a href="https://www.rheagroup.com/" title="RHEA" target="_blank" class="mx-3">RHEA System S.A.</a> 2022.</p>
57+
<p>Copyright &copy; <a href="https://www.rheagroup.com/" title="RHEA" target="_blank" class="mx-3">RHEA System S.A.</a> 2022-2023.</p>
5858
</div>
5959
</div>
6060

0 commit comments

Comments
 (0)