|
20 | 20 |
|
21 | 21 | namespace SysML2.NET.Viewer.Tests.Services.Authentication |
22 | 22 | { |
23 | | - using System; |
24 | | - using System.Threading; |
25 | | - using System.Threading.Tasks; |
| 23 | + using System; |
| 24 | + using System.Threading; |
| 25 | + using System.Threading.Tasks; |
26 | 26 |
|
27 | | - using Blazored.SessionStorage; |
28 | | - |
29 | | - using Moq; |
| 27 | + using Blazored.SessionStorage; |
| 28 | + |
| 29 | + using Moq; |
30 | 30 |
|
31 | | - using NUnit.Framework; |
| 31 | + using NUnit.Framework; |
32 | 32 |
|
33 | | - using SySML2.NET.REST; |
34 | | - using SysML2.NET.Viewer.Services.Authentication; |
| 33 | + using SySML2.NET.REST; |
| 34 | + using SysML2.NET.Viewer.Services.Authentication; |
35 | 35 |
|
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; |
43 | 43 |
|
44 | | - private Mock<IRestClient> restClient; |
| 44 | + private Mock<IRestClient> restClient; |
45 | 45 |
|
46 | | - private AnonymousAuthenticationStateProvider authenticationStateProvider; |
| 46 | + private AnonymousAuthenticationStateProvider authenticationStateProvider; |
47 | 47 |
|
48 | | - private AuthenticationService authenticationService; |
| 48 | + private AuthenticationService authenticationService; |
49 | 49 |
|
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); |
56 | 56 |
|
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 | + } |
59 | 59 |
|
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); |
66 | 66 |
|
67 | | - Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Success)); |
68 | | - } |
| 67 | + Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Success)); |
| 68 | + } |
69 | 69 |
|
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(); |
74 | 74 |
|
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>(); |
78 | 78 |
|
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); |
80 | 80 |
|
81 | | - Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Fail)); |
82 | | - } |
| 81 | + Assert.That(result, Is.EqualTo(AuthenticationStatusKind.Fail)); |
| 82 | + } |
83 | 83 |
|
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(); |
88 | 88 |
|
89 | | - await this.authenticationService.Logout(cts.Token); |
| 89 | + await this.authenticationService.Logout(cts.Token); |
90 | 90 |
|
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 | + } |
94 | 94 | } |
0 commit comments