From 05cf9a8305b56842379154a485bcb8e53bd58c08 Mon Sep 17 00:00:00 2001 From: Robbware Date: Tue, 3 Oct 2023 16:28:54 +0100 Subject: [PATCH] Add basic coverage for the MultiComboBox component. --- .../Components/MultiComboBoxTestFixture.cs | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 COMET.Web.Common.Tests/Components/MultiComboBoxTestFixture.cs diff --git a/COMET.Web.Common.Tests/Components/MultiComboBoxTestFixture.cs b/COMET.Web.Common.Tests/Components/MultiComboBoxTestFixture.cs new file mode 100644 index 00000000..a5c92ba9 --- /dev/null +++ b/COMET.Web.Common.Tests/Components/MultiComboBoxTestFixture.cs @@ -0,0 +1,90 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// 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 . +// +// -------------------------------------------------------------------------------------------------------------------- + +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.Authorization.Infrastructure; + +using TestContext = Bunit.TestContext; + +using NUnit.Framework; + +[TestFixture] +public class MultiComboBoxTestFixture +{ + private TestContext context; + private IRenderedComponent> component; + private List availableCategories; + + [SetUp] + public void SetUp() + { + this.context = new TestContext(); + this.context.ConfigureDevExpressBlazor(); + + this.availableCategories = new List + { + new() { Name = "Category" } + }; + + this.component = this.context.RenderComponent>(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); + }); + } + + [Test] + public void 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); + }); + + this.component.Render(); + + var comboBox = this.component.FindComponent>(); + + Assert.Multiple(() => + { + Assert.IsNotNull(comboBox); + }); + } +}