// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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; using System.Collections.Generic; using System.Linq; using Deltares.Dam.Data; using Deltares.Dam.Forms; using NUnit.Framework; namespace Deltares.Dam.Tests { public class DamContextTest { private DamContext context; private Type knownType = typeof(Scenario); [SetUp] public void SetUp() { context = new DamContext(); } [Test] public void DamContext_GetColumnNamedFiltersOfKnownType_ReturnListOfKnownNamedFilters() { // setup // call var result = context.GetColumnNamedFilters(knownType); // assert Assert.NotNull(result); foreach (var knownFilter in result) { Assert.NotNull(context.GetFilteredColumns(knownType, knownFilter)); } } [Test] public void DamContext_GetColumNamedFiltersOfUnknownType_ReturnsNull() { // setup // call var result = context.GetColumnNamedFilters(GetType()); // assert Assert.IsNull(result); } [Test] public void DamContext_GetNamedFiltersOfKnownTypeUnknownFilter_ReturnsNull() { // setup var unknownNamedFilter = "UnknownNamedFilter"; var namedFilters = context.GetColumnNamedFilters(knownType); CollectionAssert.DoesNotContain(namedFilters,unknownNamedFilter); // call var result = context.GetFilteredColumns(knownType, unknownNamedFilter); // assert Assert.IsNull(result); } [Test] public void DamContext_GetNamedFiltersOfUnknownTypeRandomFilter_ReturnsNull() { // setup var randomNamedFilter = "RandomNamedFilter"; // call var result = context.GetFilteredColumns(GetType(), randomNamedFilter); // assert Assert.IsNull(result); } [Test] public void DamContext_GetNamedFiltersOfKnownTypeKnownFilter_ReturnsListOfPropertyNamesInType() { // setup var namedFilters = context.GetColumnNamedFilters(knownType); var knownNamedFilter = namedFilters.First(); // call var result = context.GetFilteredColumns(knownType, knownNamedFilter); // assert Assert.IsNotNull(result); foreach (var propertyName in result) { Assert.IsNotEmpty(knownType.GetMember(propertyName)); } } } }