From 3defb9eb9294fe48a8b7e47d340e80c654365201 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozmic Date: Sun, 1 Dec 2013 10:52:24 +1000 Subject: [PATCH] more tests and indention fixes --- .../Castle.Core.Tests.csproj | 1 + .../ClassProxyWithDefaultValuesTestCase.cs | 131 ++++++++++-------- ...MethodWithParameterWithNullDefaultValue.cs | 48 +++---- ...MethodWithParameterWithNullDefaultValue.cs | 21 +++ 4 files changed, 117 insertions(+), 84 deletions(-) create mode 100644 src/Castle.Core.Tests/DynamicProxy.Tests/Interfaces/InterfaceWithMethodWithParameterWithNullDefaultValue.cs diff --git a/src/Castle.Core.Tests/Castle.Core.Tests.csproj b/src/Castle.Core.Tests/Castle.Core.Tests.csproj index cc6dbcc80e..20a80fe41c 100644 --- a/src/Castle.Core.Tests/Castle.Core.Tests.csproj +++ b/src/Castle.Core.Tests/Castle.Core.Tests.csproj @@ -254,6 +254,7 @@ + diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/ClassProxyWithDefaultValuesTestCase.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/ClassProxyWithDefaultValuesTestCase.cs index 77eea4011c..2d4d93793f 100644 --- a/src/Castle.Core.Tests/DynamicProxy.Tests/ClassProxyWithDefaultValuesTestCase.cs +++ b/src/Castle.Core.Tests/DynamicProxy.Tests/ClassProxyWithDefaultValuesTestCase.cs @@ -1,61 +1,72 @@ -// Copyright 2004-2013 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Castle.DynamicProxy.Tests -{ - using System.Linq; - - using Castle.DynamicProxy.Tests.Classes; - - using CastleTests.DynamicProxy.Tests.Classes; - - using NUnit.Framework; - - [TestFixture] - public class ClassProxyWithDefaultValuesTestCase : BasePEVerifyTestCase - { -#if DOTNET45 - [Test] - public void MethodParameterWithDefaultValue_DefaultValueIsSetOnProxiedMethodAsWell() - { - var proxiedType = generator.CreateClassProxy().GetType(); - - var parameter = proxiedType.GetMethod("Method").GetParameters().Single(paramInfo => paramInfo.Name == "value"); - - Assert.True(parameter.HasDefaultValue); - Assert.AreEqual(3, parameter.DefaultValue); - } - - [Test] - public void MethodParameterWithDefaultValue_DefaultValueNullIsSetOnProxiedMethodAsWell() - { - var proxiedType = generator.CreateClassProxy().GetType(); - - var parameter = proxiedType.GetMethod("Method").GetParameters().Single(paramInfo => paramInfo.Name == "value"); - - - Assert.False(parameter.HasDefaultValue); - } - - [Test] - public void MethodParameterWithDefaultValue_UseNullDefaultValue() - { - var proxiedType = generator.CreateClassProxy(); - var result = proxiedType.Method(); - - Assert.IsTrue(result); - } -#endif - } +// Copyright 2004-2013 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.DynamicProxy.Tests +{ + using System.Linq; + + using Castle.DynamicProxy.Tests.Classes; + using Castle.DynamicProxy.Tests.Interceptors; + + using CastleTests.DynamicProxy.Tests.Classes; + using CastleTests.DynamicProxy.Tests.Interfaces; + + using NUnit.Framework; + + [TestFixture] + public class ClassProxyWithDefaultValuesTestCase : BasePEVerifyTestCase + { +#if DOTNET45 + [Test] + public void MethodParameterWithDefaultValue_DefaultValueIsSetOnProxiedMethodAsWell() + { + var proxiedType = generator.CreateClassProxy().GetType(); + + var parameter = proxiedType.GetMethod("Method").GetParameters().Single(paramInfo => paramInfo.Name == "value"); + + Assert.True(parameter.HasDefaultValue); + Assert.AreEqual(3, parameter.DefaultValue); + } + + [Test] + public void MethodParameterWithDefaultValue_DefaultValueNullIsSetOnProxiedMethodAsWell() + { + var proxiedType = generator.CreateClassProxy().GetType(); + + var parameter = proxiedType.GetMethod("Method").GetParameters().Single(paramInfo => paramInfo.Name == "value"); + + Assert.False(parameter.HasDefaultValue); + } + + [Test] + public void MethodParameterWithDefaultValue_UseNullDefaultValue_class_proxy() + { + var proxy = generator.CreateClassProxy(); + var result = proxy.Method(); + + Assert.IsTrue(result); + } + + [Test] + public void MethodParameterWithDefaultValue_UseNullDefaultValue_interface_proxy() + { + var proxy = generator.CreateInterfaceProxyWithoutTarget( + new SetReturnValueInterceptor(true)); + var result = proxy.Method(); + + Assert.IsTrue(result); + } +#endif + } } \ No newline at end of file diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/Classes/ClassWithMethodWithParameterWithNullDefaultValue.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/Classes/ClassWithMethodWithParameterWithNullDefaultValue.cs index 52e21bee90..6db0335699 100644 --- a/src/Castle.Core.Tests/DynamicProxy.Tests/Classes/ClassWithMethodWithParameterWithNullDefaultValue.cs +++ b/src/Castle.Core.Tests/DynamicProxy.Tests/Classes/ClassWithMethodWithParameterWithNullDefaultValue.cs @@ -1,24 +1,24 @@ -// Copyright 2004-2013 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace CastleTests.DynamicProxy.Tests.Classes -{ - public class ClassWithMethodWithParameterWithNullDefaultValue - { - public virtual bool Method(int? value = null) - { - return value == null; - } - } -} +// Copyright 2004-2013 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace CastleTests.DynamicProxy.Tests.Classes +{ + public class ClassWithMethodWithParameterWithNullDefaultValue + { + public virtual bool Method(int? value = null) + { + return value == null; + } + } +} \ No newline at end of file diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/Interfaces/InterfaceWithMethodWithParameterWithNullDefaultValue.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/Interfaces/InterfaceWithMethodWithParameterWithNullDefaultValue.cs new file mode 100644 index 0000000000..0c66901f80 --- /dev/null +++ b/src/Castle.Core.Tests/DynamicProxy.Tests/Interfaces/InterfaceWithMethodWithParameterWithNullDefaultValue.cs @@ -0,0 +1,21 @@ +// Copyright 2004-2013 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace CastleTests.DynamicProxy.Tests.Interfaces +{ + public interface InterfaceWithMethodWithParameterWithNullDefaultValue + { + bool Method(int? value = null); + } +} \ No newline at end of file