mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
moved all sources to trunk directory
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@693 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
commit
a22b7578bd
392 changed files with 61489 additions and 0 deletions
101
Greenshot/Test/Drawing/Properties/SerializationTest.cs
Normal file
101
Greenshot/Test/Drawing/Properties/SerializationTest.cs
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program 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 1 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Drawing.Filters;
|
||||
using Greenshot.Helpers;
|
||||
|
||||
namespace Greenshot.Test.Drawing.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of SerializationTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class SerializationTest
|
||||
{
|
||||
|
||||
public SerializationTest()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeField() {
|
||||
Field f = FieldFactory.CreateField(FieldType.ARROWHEADS);
|
||||
f.Value = ArrowContainer.ArrowHeadCombination.BOTH;
|
||||
|
||||
Field clone = (Field) Objects.DeepClone(f);
|
||||
Assert.AreEqual(f, clone);
|
||||
Assert.AreEqual(f.Value, clone.Value);
|
||||
Assert.AreEqual(f.Scope, clone.Scope);
|
||||
|
||||
f.Scope = this.GetType().ToString();
|
||||
|
||||
clone = (Field) Objects.DeepClone(f);
|
||||
Assert.AreEqual(f, clone);
|
||||
Assert.AreEqual(f.Value, clone.Value);
|
||||
Assert.AreEqual(f.Scope, clone.Scope);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeFieldHolder() {
|
||||
AbstractFieldHolder afh = new TestFieldHolder();
|
||||
AbstractFieldHolder clone = (AbstractFieldHolder)Objects.DeepClone(afh);
|
||||
Assert.AreEqual(afh.GetFields(), clone.GetFields());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeFilter() {
|
||||
PixelizationFilter pf = new PixelizationFilter(new FilterContainer(new Surface()));
|
||||
pf.SetFieldValue(FieldType.PIXEL_SIZE, 89);
|
||||
|
||||
PixelizationFilter clone = (PixelizationFilter) Objects.DeepClone(pf);
|
||||
Assert.AreEqual(pf.GetFields(), clone.GetFields());
|
||||
Assert.AreEqual(pf.GetField(FieldType.PIXEL_SIZE), clone.GetField(FieldType.PIXEL_SIZE));
|
||||
Assert.AreEqual(pf.GetFieldValueAsInt(FieldType.PIXEL_SIZE), clone.GetFieldValueAsInt(FieldType.PIXEL_SIZE));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeFieldHolderWithChildren() {
|
||||
AbstractFieldHolderWithChildren afh = new TestFieldHolderWithChildren();
|
||||
AbstractFieldHolderWithChildren clone = (AbstractFieldHolderWithChildren)Objects.DeepClone(afh);
|
||||
Assert.AreEqual(afh.GetFields(), clone.GetFields());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeFilterContainer() {
|
||||
ObfuscateContainer oc = new ObfuscateContainer(new Surface());
|
||||
|
||||
ObfuscateContainer clone = (ObfuscateContainer)Objects.DeepClone(oc);
|
||||
Assert.AreEqual(oc.Children.GetType(), clone.Children.GetType());
|
||||
System.Collections.Generic.List<Field> ocFields = oc.GetFields();
|
||||
System.Collections.Generic.List<Field> cloneFields = clone.GetFields();
|
||||
Assert.AreEqual(ocFields, cloneFields);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private class TestFieldHolder : AbstractFieldHolder {}
|
||||
[Serializable]
|
||||
private class TestFieldHolderWithChildren : AbstractFieldHolderWithChildren {}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue