// Copyright (C) Stichting Deltares and State of the Netherlands 2025. All rights reserved.
//
// This file is part of Riskeer.
//
// Riskeer 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.Windows.Media;
using Core.Common.Controls.Views;
using Core.Gui.Plugin;
using NUnit.Framework;
using Rhino.Mocks;
namespace Core.Gui.Test.Plugin
{
[TestFixture]
public class ViewInfoTest
{
[Test]
public void DefaultConstructor_ExpectedValues()
{
// Call
var viewInfo = new ViewInfo();
// Assert
Assert.IsNull(viewInfo.DataType);
Assert.IsNull(viewInfo.ViewDataType);
Assert.IsNull(viewInfo.ViewType);
Assert.IsNull(viewInfo.Description);
Assert.IsNull(viewInfo.GetViewName);
Assert.IsNull(viewInfo.GetSymbol);
Assert.IsNull(viewInfo.GetFontFamily);
Assert.IsNull(viewInfo.AdditionalDataCheck);
Assert.IsNull(viewInfo.GetViewData);
Assert.IsNull(viewInfo.AfterCreate);
Assert.IsNull(viewInfo.CloseForData);
Assert.IsNotNull(viewInfo.CreateInstance);
}
[Test]
public void SimpleProperties_SetNewValues_GetNewlySetValues()
{
// Setup
var mocks = new MockRepository();
var viewInstance = mocks.Stub();
mocks.ReplayAll();
var viewInfo = new ViewInfo();
Type newDataType = typeof(int);
Type newViewDataType = typeof(string);
Type viewType = typeof(StringView);
const string newDescription = "";
string GetViewName(IView view, object o) => "";
string GetSymbol() => "";
FontFamily GetFontFamily() => new FontFamily();
bool AdditionalDataCheck(object o) => true;
object GetViewData(object o) => 45;
void AfterCreate(IView view, object o) {}
bool CloseForData(IView view, object o) => true;
IView CreateInstance(object o) => viewInstance;
// Call
viewInfo.DataType = newDataType;
viewInfo.ViewDataType = newViewDataType;
viewInfo.ViewType = viewType;
viewInfo.Description = newDescription;
viewInfo.GetViewName = GetViewName;
viewInfo.GetSymbol = GetSymbol;
viewInfo.GetFontFamily = GetFontFamily;
viewInfo.AdditionalDataCheck = AdditionalDataCheck;
viewInfo.GetViewData = GetViewData;
viewInfo.AfterCreate = AfterCreate;
viewInfo.CloseForData = CloseForData;
viewInfo.CreateInstance = CreateInstance;
// Assert
Assert.AreEqual(newDataType, viewInfo.DataType);
Assert.AreEqual(newViewDataType, viewInfo.ViewDataType);
Assert.AreEqual(viewType, viewInfo.ViewType);
Assert.AreEqual(newDescription, viewInfo.Description);
Assert.AreEqual((Func) GetViewName, viewInfo.GetViewName);
Assert.AreEqual((Func) GetSymbol, viewInfo.GetSymbol);
Assert.AreEqual((Func) GetFontFamily, viewInfo.GetFontFamily);
Assert.AreEqual((Func