|
| 1 | +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#if NETCOREAPP3_0_OR_GREATER |
| 16 | + |
| 17 | +using System.Reflection; |
| 18 | + |
| 19 | +using NUnit.Framework; |
| 20 | + |
| 21 | +namespace Castle.DynamicProxy.Tests |
| 22 | +{ |
| 23 | + [TestFixture] |
| 24 | + public class DefaultInterfaceMembersTestCase : BasePEVerifyTestCase |
| 25 | + { |
| 26 | + [Test] |
| 27 | + public void Can_proxy_interface_with_sealed_method() |
| 28 | + { |
| 29 | + _ = generator.CreateInterfaceProxyWithoutTarget<IHaveSealedMethod>(); |
| 30 | + } |
| 31 | + |
| 32 | + [Test] |
| 33 | + public void Can_invoke_sealed_method_in_proxied_interface() |
| 34 | + { |
| 35 | + var proxy = generator.CreateInterfaceProxyWithoutTarget<IHaveSealedMethod>(); |
| 36 | + var invokedMethod = proxy.SealedMethod(); |
| 37 | + Assert.AreEqual(typeof(IHaveSealedMethod).GetMethod(nameof(IHaveSealedMethod.SealedMethod)), invokedMethod); |
| 38 | + } |
| 39 | + |
| 40 | + public interface IHaveSealedMethod |
| 41 | + { |
| 42 | + sealed MethodBase SealedMethod() |
| 43 | + { |
| 44 | + return MethodBase.GetCurrentMethod(); |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +#endif |
0 commit comments