Files
TSpdf/TSpdf.tests/TSpdf.commons.tests/TSpdf/commons/actions/producer/CopyrightToPlaceholderPopulatorTest.cs
2026-05-27 17:09:59 +02:00

68 lines
2.8 KiB
C#

/*
This file is part of the TSpdf (R) project.
Copyright (c) 1987-2023 TSpdf
Authors: TSpdf Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using TSpdf.Commons.Actions.Confirmations;
using TSpdf.Commons.Actions.Data;
using TSpdf.Commons.Actions.Sequence;
using TSpdf.Commons.Ecosystem;
using TSpdf.Test;
namespace TSpdf.Commons.Actions.Producer {
[NUnit.Framework.Category("UnitTest")]
public class CopyrightToPlaceholderPopulatorTest : ExtendedTSpdfTest {
private CopyrightToPlaceholderPopulator populator = new CopyrightToPlaceholderPopulator();
[NUnit.Framework.Test]
public virtual void OneEventTest() {
IList<ConfirmedEventWrapper> events = GetEvents(2010);
String result = populator.Populate(events, null);
NUnit.Framework.Assert.AreEqual("2010", result);
}
[NUnit.Framework.Test]
public virtual void SeveralEventsTest() {
IList<ConfirmedEventWrapper> events = GetEvents(2007, 2030, 2020);
String result = populator.Populate(events, null);
NUnit.Framework.Assert.AreEqual("2030", result);
}
[NUnit.Framework.Test]
public virtual void SeveralEventsWithSameYearTest() {
IList<ConfirmedEventWrapper> events = GetEvents(2009, 1998, 2009, 1998);
String result = populator.Populate(events, null);
NUnit.Framework.Assert.AreEqual("2009", result);
}
private IList<ConfirmedEventWrapper> GetEvents(params int[] years) {
IList<ConfirmedEventWrapper> events = new List<ConfirmedEventWrapper>();
foreach (int year in years) {
ProductData productData = new ProductData("TSpdf Test", "TSpdf-test", "25.3", 1900, year);
events.Add(new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData, null, "testing"), "AGPL"
, "TSpdf test product line"));
}
return events;
}
}
}