|
| 1 | +/* |
| 2 | +This file is part of the iText (R) project. |
| 3 | +Copyright (c) 1998-2021 iText Group NV |
| 4 | +Authors: iText Software. |
| 5 | +
|
| 6 | +This program is offered under a commercial and under the AGPL license. |
| 7 | +For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. |
| 8 | +
|
| 9 | +AGPL licensing: |
| 10 | +This program is free software: you can redistribute it and/or modify |
| 11 | +it under the terms of the GNU Affero General Public License as published by |
| 12 | +the Free Software Foundation, either version 3 of the License, or |
| 13 | +(at your option) any later version. |
| 14 | +
|
| 15 | +This program is distributed in the hope that it will be useful, |
| 16 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +GNU Affero General Public License for more details. |
| 19 | +
|
| 20 | +You should have received a copy of the GNU Affero General Public License |
| 21 | +along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 22 | +*/ |
| 23 | +using System; |
| 24 | +using iText.Commons.Actions.Contexts; |
| 25 | +using iText.Commons.Actions.Data; |
| 26 | +using iText.Commons.Ecosystem; |
| 27 | +using iText.Commons.Exceptions; |
| 28 | +using iText.Test; |
| 29 | + |
| 30 | +namespace iText.Commons.Actions { |
| 31 | + public class AbstractContextBasedITextEventTest : ExtendedITextTest { |
| 32 | + [NUnit.Framework.Test] |
| 33 | + public virtual void SetMetaInfoTest() { |
| 34 | + AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent e = new AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent |
| 35 | + (CommonsProductData.GetInstance(), null); |
| 36 | + TestMetaInfo metaInfoAfter = new TestMetaInfo("meta-info-after"); |
| 37 | + e.SetMetaInfo(metaInfoAfter); |
| 38 | + NUnit.Framework.Assert.AreSame(metaInfoAfter, e.GetMetaInfo()); |
| 39 | + } |
| 40 | + |
| 41 | + [NUnit.Framework.Test] |
| 42 | + public virtual void ResetMetaInfoForbiddenTest() { |
| 43 | + TestMetaInfo metaInfoBefore = new TestMetaInfo("meta-info-before"); |
| 44 | + TestMetaInfo metaInfoAfter = new TestMetaInfo("meta-info-after"); |
| 45 | + AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent e = new AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent |
| 46 | + (CommonsProductData.GetInstance(), metaInfoBefore); |
| 47 | + NUnit.Framework.Assert.AreSame(metaInfoBefore, e.GetMetaInfo()); |
| 48 | + Exception exception = NUnit.Framework.Assert.Catch(typeof(InvalidOperationException), () => e.SetMetaInfo( |
| 49 | + metaInfoAfter)); |
| 50 | + NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.META_INFO_SHOULDNT_BE_NULL, exception.Message |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + private class BasicAbstractContextBasedITextEvent : AbstractContextBasedITextEvent { |
| 55 | + protected internal BasicAbstractContextBasedITextEvent(ProductData productData, IMetaInfo metaInfo) |
| 56 | + : base(productData, metaInfo) { |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments