-
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.
[ADD] Save and reuse data in open tab component; fixes #724
* [ADD] Save and reuse data while opening tabs * Add unit test and fix bugs * Fix unit tests * Fix unit tests, missing ICacheService * Changes according to SQ * Add new unit tests
- Loading branch information
1 parent
a200985
commit 208d88b
Showing
18 changed files
with
451 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
116 changes: 116 additions & 0 deletions
116
COMET.Web.Common.Tests/Services/CacheService/CacheServiceTestFixture.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,116 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="CacheServiceTestFixture.cs" company="Starion Group S.A."> | ||
// Copyright (c) 2023-2024 Starion Group S.A. | ||
// | ||
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar | ||
// | ||
// This file is part of CDP4-COMET WEB Community Edition | ||
// The CDP4-COMET WEB Community Edition is the Starion 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.Services.CacheService | ||
{ | ||
using CDP4Common.EngineeringModelData; | ||
|
||
using COMET.Web.Common.Enumerations; | ||
using COMET.Web.Common.Services.Cache; | ||
|
||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class CacheServiceTestFixture | ||
{ | ||
private CacheService cacheService; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
this.cacheService = new CacheService(); | ||
} | ||
|
||
[Test] | ||
public void VerifyAddNewKey() | ||
{ | ||
var engineeringModel = new EngineeringModel(); | ||
var browserSessionSettingKey = BrowserSessionSettingKey.LastUsedEngineeringModel; | ||
|
||
Assert.That(() => this.cacheService.AddOrUpdateBrowserSessionSetting(browserSessionSettingKey, engineeringModel), Throws.Nothing); | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result), Is.True); | ||
|
||
Assert.That(result, Is.EqualTo(engineeringModel)); | ||
} | ||
|
||
[Test] | ||
public void VerifyKeyDoesNotExistWorksAsExpected() | ||
{ | ||
var browserSessionSettingKey = BrowserSessionSettingKey.LastUsedEngineeringModel; | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result), Is.False); | ||
|
||
Assert.That(result, Is.Null); | ||
} | ||
|
||
[Test] | ||
public void VerifyOverwriteExistingKey() | ||
{ | ||
var engineeringModel1 = new EngineeringModel(); | ||
var browserSessionSettingKey = BrowserSessionSettingKey.LastUsedEngineeringModel; | ||
|
||
Assert.That(() => this.cacheService.AddOrUpdateBrowserSessionSetting(browserSessionSettingKey, engineeringModel1), Throws.Nothing); | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result), Is.True); | ||
|
||
Assert.That(result, Is.EqualTo(engineeringModel1)); | ||
|
||
var engineeringModel2 = new EngineeringModel(); | ||
|
||
Assert.That(() => this.cacheService.AddOrUpdateBrowserSessionSetting(browserSessionSettingKey, engineeringModel2), Throws.Nothing); | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result2), Is.True); | ||
|
||
Assert.That(result2, Is.EqualTo(engineeringModel2)); | ||
} | ||
|
||
[Test] | ||
public void VerifyGetOrAddKey() | ||
{ | ||
var engineeringModel1 = new EngineeringModel(); | ||
var browserSessionSettingKey = BrowserSessionSettingKey.LastUsedEngineeringModel; | ||
|
||
Assert.That(this.cacheService.TryGetOrAddBrowserSessionSetting(browserSessionSettingKey, engineeringModel1, out var result), Is.True); | ||
|
||
Assert.That(result, Is.EqualTo(engineeringModel1)); | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result2), Is.True); | ||
|
||
Assert.That(result2, Is.EqualTo(engineeringModel1)); | ||
|
||
var engineeringModel2 = new EngineeringModel(); | ||
|
||
Assert.That(this.cacheService.TryGetOrAddBrowserSessionSetting(browserSessionSettingKey, engineeringModel2, out var result3), Is.True); | ||
|
||
Assert.That(result3, Is.EqualTo(engineeringModel1)); | ||
|
||
Assert.That(this.cacheService.TryGetBrowserSessionSetting(browserSessionSettingKey, out var result4), Is.True); | ||
|
||
Assert.That(result4, Is.EqualTo(engineeringModel1)); | ||
} | ||
} | ||
} |
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
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,50 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="BrowserSessionSettings.cs" company="Starion Group S.A."> | ||
// Copyright (c) 2024 Starion Group S.A. | ||
// | ||
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua | ||
// | ||
// This file is part of COMET WEB Community Edition | ||
// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. | ||
// | ||
// The COMET WEB Community Edition is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Affero General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 3 of the License, or (at your option) any later version. | ||
// | ||
// The COMET WEB Community Edition is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace COMET.Web.Common.Enumerations | ||
{ | ||
using CDP4Common.EngineeringModelData; | ||
using CDP4Common.SiteDirectoryData; | ||
|
||
/// <summary> | ||
/// En enumeration of possible keys to be used to store and retrieve cached BrowserSessionSettings | ||
/// </summary> | ||
public enum BrowserSessionSettingKey | ||
{ | ||
/// <summary> | ||
/// Key to handle the last selected <see cref="EngineeringModel"/> | ||
/// </summary> | ||
LastUsedEngineeringModel, | ||
|
||
/// <summary> | ||
/// Key to handle the last selected <see cref="IterationSetup"/> | ||
/// </summary> | ||
LastUsedIterationData, | ||
|
||
/// <summary> | ||
/// Key to handle the last selected <see cref="DomainOfExpertise"/> | ||
/// </summary> | ||
LastUsedDomainOfExpertise | ||
} | ||
} |
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
Oops, something went wrong.