// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Collections.Generic; using System.Drawing; using Core.Common.Controls.DataGrid; using NUnit.Framework; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.TestUtil { /// /// Class that can be used to assert properties of a . /// public static class FailureMechanismSectionResultRowTestHelper { /// /// Gets a collection of test cases to test the colors belonging to various /// values. /// public static IEnumerable CategoryGroupColorCases { get { yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.NotApplicable, Color.FromArgb(255, 255, 255)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.None, Color.FromArgb(255, 255, 255)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.Iv, Color.FromArgb(0, 255, 0)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.IIv, Color.FromArgb(118, 147, 60)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.IIIv, Color.FromArgb(255, 255, 0)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.IVv, Color.FromArgb(204, 192, 218)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.Vv, Color.FromArgb(255, 153, 0)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.VIv, Color.FromArgb(255, 0, 0)); yield return new TestCaseData(FailureMechanismSectionAssemblyCategoryGroup.VIIv, Color.FromArgb(255, 255, 255)); } } /// /// Asserts the state of the . /// /// The /// to assert. /// Indicator whether the state should be enabled or not. /// Indicator whether the state should be read-only or not. /// Thrown when the state of /// is not equal to the given parameters. public static void AssertColumnState(DataGridViewColumnStateDefinition columnStateDefinition, bool isEnabled, bool isReadOnly = false) { if (isEnabled) { AssertColumnStateIsEnabled(columnStateDefinition, isReadOnly); } else { AssertColumnStateIsDisabled(columnStateDefinition); } } /// /// Asserts the state of the with an expected /// background color. /// /// The /// to assert. /// The expected background color of the column style. /// Thrown when the state of /// is not the same as the expected state. public static void AssertColumnWithColorState(DataGridViewColumnStateDefinition columnStateDefinition, Color expectedBackgroundColor) { Assert.IsTrue(columnStateDefinition.ReadOnly); Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), columnStateDefinition.Style.TextColor); Assert.AreEqual(expectedBackgroundColor, columnStateDefinition.Style.BackgroundColor); } /// /// Asserts that the state of the is disabled. /// /// The /// to assert. /// Thrown when the state of /// is not the same as the expected disabled state. public static void AssertColumnStateIsDisabled(DataGridViewColumnStateDefinition columnStateDefinition) { Assert.AreEqual(CellStyle.Disabled, columnStateDefinition.Style); Assert.IsTrue(columnStateDefinition.ReadOnly); Assert.AreEqual(string.Empty, columnStateDefinition.ErrorText); } /// /// Asserts that the state of the is enabled. /// /// The /// to assert. /// Indicator whether the column state should be read-only or not. /// Thrown when the state of /// is not the same as the expected enabled state. public static void AssertColumnStateIsEnabled(DataGridViewColumnStateDefinition columnStateDefinition, bool readOnly = false) { Assert.AreEqual(CellStyle.Enabled, columnStateDefinition.Style); Assert.AreEqual(readOnly, columnStateDefinition.ReadOnly); Assert.AreEqual(string.Empty, columnStateDefinition.ErrorText); } /// /// Asserts that the column state definition is added and not null. /// /// The column state definitions to assert. /// The index to assert for. /// Thrown when the index is not added to the /// or the column state definition is null. public static void AssertColumnStateDefinition(IDictionary columnStateDefinitions, int index) { Assert.IsTrue(columnStateDefinitions.ContainsKey(index)); Assert.IsNotNull(columnStateDefinitions[index]); } } }