From 7a9b5552f1a4410830b081cd81c003fde7732cd4 Mon Sep 17 00:00:00 2001 From: "ken.egozi" Date: Mon, 7 Apr 2008 22:14:56 +0000 Subject: [PATCH] applying a patch from Dusty Chadland (with a few changes), allowing for better separation of tests that renders emails using MockEngineContext git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4993 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- .../Castle.MonoRail.Framework.Tests-vs2005.csproj | 6 ++- .../Castle.MonoRail.Framework.Tests-vs2008.csproj | 1 + .../MockObjectTests/MockRailsEngineContextTest.cs | 45 ++++++++++++++++++++++ .../Test/MockEngineContext.cs | 4 +- 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 MonoRail/Castle.MonoRail.Framework.Tests/MockObjectTests/MockRailsEngineContextTest.cs diff --git a/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2005.csproj b/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2005.csproj index ebe6e21ba..05e3c4cd1 100644 --- a/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2005.csproj +++ b/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2005.csproj @@ -234,6 +234,9 @@ + + Code + @@ -257,6 +260,7 @@ + @@ -309,4 +313,4 @@ copy "$(ProjectDir)\App.config" "$(TargetPath).config" - \ No newline at end of file + diff --git a/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2008.csproj b/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2008.csproj index 63a6b3d80..feee51847 100644 --- a/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2008.csproj +++ b/MonoRail/Castle.MonoRail.Framework.Tests/Castle.MonoRail.Framework.Tests-vs2008.csproj @@ -199,6 +199,7 @@ + diff --git a/MonoRail/Castle.MonoRail.Framework.Tests/MockObjectTests/MockRailsEngineContextTest.cs b/MonoRail/Castle.MonoRail.Framework.Tests/MockObjectTests/MockRailsEngineContextTest.cs new file mode 100644 index 000000000..717d0d078 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Framework.Tests/MockObjectTests/MockRailsEngineContextTest.cs @@ -0,0 +1,45 @@ +// Copyright 2004-2008 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.MonoRail.Framework.Tests.MockObjectTests +{ + using Castle.MonoRail.Framework.Test; + using NUnit.Framework; + using Castle.MonoRail.TestSupport; + + [TestFixture] + public class MockRailsEngineContextTest : BaseControllerTest + { + private DummyController controller; + + [Test] + public void AddMailTemplateRendered_Expect_A_Copy_Of_Properties() + { + controller = new DummyController(); + PrepareController(controller); + controller.Context.Services.EmailTemplateService = new MockEmailTemplateService((MockEngineContext)controller.Context); + string templateName = "welcome"; + + controller.PropertyBag["Value"] = "One"; + controller.RenderMailMessage(templateName, null, controller.PropertyBag); + controller.PropertyBag["Value"] = "Two"; + controller.RenderMailMessage(templateName, null, controller.PropertyBag); + + Assert.AreEqual(RenderedEmailTemplates[0].Parameters["Value"], "One"); + Assert.AreEqual(RenderedEmailTemplates[1].Parameters["Value"], "Two"); + } + + private class DummyController : Controller {} + } +} diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs index 551a4e9ad..719afbdae 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs @@ -317,7 +317,7 @@ namespace Castle.MonoRail.Framework.Test public RenderedEmailTemplate(string name, IDictionary parameters) { this.name = name; - this.parameters = parameters; + this.parameters = new Hashtable(parameters); } /// @@ -339,4 +339,4 @@ namespace Castle.MonoRail.Framework.Test } } } -} \ No newline at end of file +} -- 2.11.4.GIT