// Copyright (C) Stichting Deltares 2016. 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 Lesser 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 Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser 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; using System.ComponentModel; using System.Windows.Forms; using Core.Common.Gui.PropertyBag; using NUnit.Framework; namespace Core.Common.TestUtil { /// /// Helper class when dealing with implementations or /// other objects that are meant to be shown in the . /// public static class PropertiesTestHelper { /// /// Gets all visible property descriptors for a given 'object properties' object. /// /// The properties object. /// All visible property descriptors. public static PropertyDescriptorCollection GetAllVisiblePropertyDescriptors(object propertiesObject) { var dynamicPropertyBag = new DynamicPropertyBag(propertiesObject); return dynamicPropertyBag.GetProperties(new Attribute[] { BrowsableAttribute.Yes }); } /// /// Asserts the properties of a on required subjects. /// /// The property to be checked. /// The expected category. /// The expected name of the property shown to the user. /// The expected description of the property shown to the user. /// Indicates whether or not the property is read-only. public static void AssertRequiredPropertyDescriptorProperties(PropertyDescriptor property, string expectedCategory, string expectedDisplayName, string expectedDescription, bool isReadOnly = false) { Assert.AreEqual(isReadOnly, property.IsReadOnly); Assert.AreEqual(expectedCategory, property.Category); Assert.AreEqual(expectedDisplayName, property.DisplayName); Assert.AreEqual(expectedDescription, property.Description); } } }