-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
antoineatrhea
committed
Oct 14, 2023
1 parent
64ea608
commit 6ab52bd
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
COMET.Web.Common.Tests/Components/Applications/ApplicationTemplateTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="ApplicationTemplateTestFixture.cs" company="RHEA System S.A."> | ||
// Copyright (c) 2023 RHEA System S.A. | ||
// | ||
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine | ||
// | ||
// This file is part of COMET WEB Community Edition | ||
// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 | ||
// Annex A and Annex C. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace COMET.Web.Common.Tests.Components.Applications | ||
{ | ||
using CDP4Dal; | ||
using CDP4Dal.DAL; | ||
|
||
using COMET.Web.Common.Components.Applications; | ||
using COMET.Web.Common.Model.Configuration; | ||
using COMET.Web.Common.Services.ConfigurationService; | ||
using COMET.Web.Common.Services.SessionManagement; | ||
using COMET.Web.Common.Utilities; | ||
using COMET.Web.Common.ViewModels.Components.Applications; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
using Moq; | ||
|
||
using NUnit.Framework; | ||
|
||
using TestContext = Bunit.TestContext; | ||
|
||
[TestFixture] | ||
public class ApplicationTemplateTestFixture | ||
{ | ||
private TestContext context; | ||
private Mock<IApplicationTemplateViewModel> viewModel; | ||
private Mock<ISessionService> sessionService; | ||
private Mock<IConfigurationService> configurationService; | ||
private ServerConfiguration configuration; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
this.context = new TestContext(); | ||
this.viewModel = new Mock<IApplicationTemplateViewModel>(); | ||
this.sessionService = new Mock<ISessionService>(); | ||
this.configurationService = new Mock<IConfigurationService>(); | ||
this.configuration = new ServerConfiguration(); | ||
this.configurationService.Setup(x => x.ServerConfiguration).Returns(this.configuration); | ||
this.viewModel.Setup(x => x.SessionService).Returns(this.sessionService.Object); | ||
var session = new Mock<ISession>(); | ||
session.Setup(x => x.DataSourceUri).Returns("abc"); | ||
this.sessionService.Setup(x => x.Session).Returns(session.Object); | ||
this.context.Services.AddSingleton(this.configurationService.Object); | ||
this.context.Services.AddSingleton(this.viewModel.Object); | ||
} | ||
|
||
[Test] | ||
public void VerifyApplicationTemplateWithoutDefinedAddress() | ||
{ | ||
this.context.RenderComponent<ApplicationTemplate>(); | ||
var navigationManager = this.context.Services.GetService<NavigationManager>(); | ||
Assert.That(navigationManager.Uri, Does.Contain($"{QueryKeys.ServerKey}=abc")); | ||
} | ||
|
||
[Test] | ||
public void VerifyApplicationTemplateWithDefinedAddress() | ||
{ | ||
this.configuration.ServerAddress = "abc"; | ||
this.context.RenderComponent<ApplicationTemplate>(); | ||
var navigationManager = this.context.Services.GetService<NavigationManager>(); | ||
Assert.That(navigationManager.Uri, Does.Not.Contain($"{QueryKeys.ServerKey}=abc")); | ||
} | ||
} | ||
} |