-
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.
Merge pull request #462 from RHEAGROUP/Feat/BookApplicationImprovements
Improvements to the InputEditor
- Loading branch information
Showing
12 changed files
with
563 additions
and
88 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
109 changes: 109 additions & 0 deletions
109
COMET.Web.Common.Tests/Components/MultiComboBoxTestFixture.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,109 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="MultiComboBoxTestFixture.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. | ||
// | ||
// 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.Tests.Components | ||
{ | ||
using Bunit; | ||
|
||
using CDP4Common.DTO; | ||
|
||
using COMET.Web.Common.Components; | ||
using COMET.Web.Common.Test.Helpers; | ||
|
||
using DevExpress.Blazor; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
using TestContext = Bunit.TestContext; | ||
|
||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class MultiComboBoxTestFixture | ||
{ | ||
private TestContext context; | ||
private IRenderedComponent<MultiComboBox<Category>> component; | ||
private List<Category> availableCategories; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.context = new TestContext(); | ||
this.context.ConfigureDevExpressBlazor(); | ||
|
||
this.availableCategories = new List<Category> | ||
{ | ||
new() { Name = "Category" }, | ||
new() { Name = "Category2" }, | ||
new() { Name = "Category3" }, | ||
new() { Name = "Category4" }, | ||
new() { Name = "Category5" }, | ||
}; | ||
|
||
this.component = this.context.RenderComponent<MultiComboBox<Category>>(parameter => | ||
{ | ||
parameter.Add(p => p.Data, this.availableCategories); | ||
parameter.Add(p => p.Values, this.availableCategories); | ||
parameter.Add(p => p.ShowCheckBoxes, true); | ||
parameter.Add(p => p.MaxNumberOfChips, 2); | ||
parameter.Add(p => p.Enabled, true); | ||
|
||
parameter.Add(p => p.EditorTextTemplate, builder => | ||
{ | ||
builder.OpenElement(0, "span"); | ||
builder.AddContent(1, ""); | ||
builder.CloseElement(); | ||
}); | ||
|
||
parameter.Add(p => p.RowTemplate, value => value.Name); | ||
}); | ||
} | ||
|
||
[Test] | ||
public async Task VerifyComponent() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.IsTrue(this.component.Instance.Enabled); | ||
Assert.IsNotEmpty(this.component.Instance.Data); | ||
Assert.IsNotEmpty(this.component.Instance.Values); | ||
Assert.IsTrue(this.component.Instance.ShowCheckBoxes); | ||
Assert.IsNotNull(this.component.Instance.EditorTextTemplate); | ||
Assert.That(this.component.Instance.MaxNumberOfChips, Is.EqualTo(2)); | ||
Assert.IsNotNull(this.component.Instance.RowTemplate); | ||
}); | ||
|
||
var comboBox = this.component.FindComponent<DxComboBox<Category, Category>>(); | ||
Assert.IsNotNull(comboBox); | ||
Assert.IsNull(comboBox.Instance.Value); | ||
|
||
await this.component.InvokeAsync(() => comboBox.Instance.ShowDropDown()); | ||
|
||
var dropdownItems = this.component.FindAll(".item-template-checkbox"); | ||
Assert.IsNotNull(dropdownItems); | ||
Assert.IsNotEmpty(dropdownItems); | ||
Assert.AreEqual(this.availableCategories.Count, dropdownItems.Count); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.