Skip to content

Commit 57a7ef1

Browse files
committed
Eliminating warnings from build
Modernize Rhino usage that was resulting in warnings. Removed a few lines that were present for the sake of settings breakpoints on them.
1 parent 0652ed6 commit 57a7ef1

File tree

9 files changed

+150
-257
lines changed

9 files changed

+150
-257
lines changed

src/Castle.MonoRail.Views.Spark.Tests/SparkViewDataTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void MergingCollectionsLikeVelocity()
6363
//* engineContext.Flash
6464
//* controller.PropertyBag
6565

66-
var resource = mocks.CreateMock<IResource>();
66+
var resource = MockRepository.GenerateMock<IResource>();
6767

6868
mocks.ReplayAll();
6969

src/Castle.MonoRail.Views.Spark.Tests/SparkViewFactoryTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void Init()
5959
output = new StringWriter();
6060

6161
server = new StubServerUtility();
62-
routingEngine = mocks.CreateMock<IRoutingEngine>();
62+
routingEngine = MockRepository.GenerateMock<IRoutingEngine>();
6363
var urlBuilder = new DefaultUrlBuilder(server, routingEngine);
6464
serviceProvider.UrlBuilder = urlBuilder;
6565
serviceProvider.AddService(typeof(IUrlBuilder), urlBuilder);

src/Castle.MonoRail.Views.Spark.Tests/ViewComponents/BaseViewComponentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public virtual void Init()
5252
factory = new SparkViewFactory();
5353
factory.Service(services);
5454

55-
controller = mocks.CreateMock<IController>();
55+
controller = MockRepository.GenerateMock<IController>();
5656
controllerContext = new ControllerContext();
5757
var request = new StubRequest();
5858
request.FilePath = "";

src/Spark.Tests/CompiledViewHolderTester.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,11 @@ public void VariousKeyEqualities()
8484
[Test]
8585
public void ExpiredEntryReturnsNull()
8686
{
87-
var mocks = new MockRepository();
88-
var loader = mocks.CreateMock<ViewLoader>();
87+
var loader = MockRepository.GenerateMock<ViewLoader>();
8988

9089
isCurrent = true;
91-
Func<bool> foo = delegate { return isCurrent; };
92-
SetupResult.For(loader.IsCurrent()).Do(foo);
93-
94-
mocks.ReplayAll();
90+
Func<bool> foo = () => isCurrent;
91+
loader.Stub(x => x.IsCurrent()).Do(foo);
9592

9693
var key = BuildKey("c\\v", "shared\\m");
9794
var entry = new CompiledViewHolder.Entry { Key = key, Loader = loader };

src/Spark.Tests/Parser/ViewLoaderTester.cs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Spark.Tests.Parser
2626
[TestFixture]
2727
public class ViewLoaderTester
2828
{
29-
private MockRepository mocks;
29+
3030
private ViewLoader loader;
3131

3232
private IViewFolder viewSourceLoader;
@@ -35,26 +35,25 @@ public class ViewLoaderTester
3535
[SetUp]
3636
public void Init()
3737
{
38-
mocks = new MockRepository();
3938

40-
viewSourceLoader = mocks.CreateMock<IViewFolder>();
41-
SetupResult.For(viewSourceLoader.ListViews("home")).Return(new[] { "file.spark", "other.spark", "_comment.spark" });
42-
SetupResult.For(viewSourceLoader.ListViews("Home")).Return(new[] { "file.spark", "other.spark", "_comment.spark" });
43-
SetupResult.For(viewSourceLoader.ListViews("Account")).Return(new[] { "index.spark" });
44-
SetupResult.For(viewSourceLoader.ListViews("Shared")).Return(new[] { "layout.spark", "_header.spark", "default.spark", "_footer.spark" });
39+
viewSourceLoader = MockRepository.GenerateMock<IViewFolder>();
40+
viewSourceLoader.Stub(x => x.ListViews("home")).Return(new[] { "file.spark", "other.spark", "_comment.spark" });
41+
viewSourceLoader.Stub(x => x.ListViews("Home")).Return(new[] { "file.spark", "other.spark", "_comment.spark" });
42+
viewSourceLoader.Stub(x => x.ListViews("Account")).Return(new[] { "index.spark" });
43+
viewSourceLoader.Stub(x => x.ListViews("Shared")).Return(new[] { "layout.spark", "_header.spark", "default.spark", "_footer.spark" });
4544

46-
syntaxProvider = mocks.CreateMock<ISparkSyntaxProvider>();
45+
syntaxProvider = MockRepository.GenerateMock<ISparkSyntaxProvider>();
4746

4847
loader = new ViewLoader { ViewFolder = viewSourceLoader, SyntaxProvider = syntaxProvider };
4948
}
5049

5150
IViewFile ExpectGetChunks(string path, params Chunk[] chunks)
5251
{
53-
var source = mocks.CreateMock<IViewFile>();
52+
var source = MockRepository.GenerateMock<IViewFile>();
5453

55-
Expect.Call(viewSourceLoader.GetViewSource(path)).Return(source);
56-
Expect.Call(source.LastModified).Return(0);
57-
Expect.Call(syntaxProvider.GetChunks(null, null)).IgnoreArguments().Return(chunks);
54+
viewSourceLoader.Expect(x => x.GetViewSource(path)).Return(source);
55+
source.Expect(x => x.LastModified).Return(0);
56+
syntaxProvider.Expect(x => x.GetChunks(null, null)).IgnoreArguments().Return(chunks);
5857

5958
return source;
6059
}
@@ -63,12 +62,12 @@ IViewFile ExpectGetChunks(string path, params Chunk[] chunks)
6362
public void LoadSimpleFile()
6463
{
6564
ExpectGetChunks("home\\simple.spark", new SendLiteralChunk());
66-
SetupResult.For(viewSourceLoader.HasView("home\\_global.spark")).Return(false);
67-
SetupResult.For(viewSourceLoader.HasView("Shared\\_global.spark")).Return(false);
65+
viewSourceLoader.Stub(x => x.HasView("home\\_global.spark")).Return(false);
66+
viewSourceLoader.Stub(x => x.HasView("Shared\\_global.spark")).Return(false);
6867

69-
mocks.ReplayAll();
7068
var chunks = loader.Load("home\\simple.spark");
71-
mocks.VerifyAll();
69+
viewSourceLoader.VerifyAllExpectations();
70+
syntaxProvider.VerifyAllExpectations();
7271

7372
Assert.AreEqual(1, chunks.Count());
7473
Assert.AreEqual(1, loader.GetEverythingLoaded().Count());
@@ -78,14 +77,14 @@ public void LoadSimpleFile()
7877
public void LoadUsedFile()
7978
{
8079
ExpectGetChunks("Home\\usefile.spark", new RenderPartialChunk { Name = "mypartial" });
81-
Expect.Call(viewSourceLoader.HasView("Home\\mypartial.spark")).Return(true);
80+
viewSourceLoader.Expect(x => x.HasView("Home\\mypartial.spark")).Return(true);
8281
ExpectGetChunks("Home\\mypartial.spark", new SendLiteralChunk { Text = "Hello world" });
83-
SetupResult.For(viewSourceLoader.HasView("Home\\_global.spark")).Return(false);
84-
SetupResult.For(viewSourceLoader.HasView("Shared\\_global.spark")).Return(false);
82+
viewSourceLoader.Stub(x => x.HasView("Home\\_global.spark")).Return(false);
83+
viewSourceLoader.Stub(x => x.HasView("Shared\\_global.spark")).Return(false);
8584

86-
mocks.ReplayAll();
8785
loader.Load("Home\\usefile.spark");
88-
mocks.VerifyAll();
86+
viewSourceLoader.VerifyAllExpectations();
87+
syntaxProvider.VerifyAllExpectations();
8988

9089
Assert.AreEqual(2, loader.GetEverythingLoaded().Count());
9190
}
@@ -95,25 +94,25 @@ public void LoadUsedFile()
9594
public void LoadSharedFile()
9695
{
9796
ExpectGetChunks("Home\\usefile.spark", new RenderPartialChunk { Name = "mypartial" });
98-
Expect.Call(viewSourceLoader.HasView("Home\\mypartial.spark")).Return(false);
99-
Expect.Call(viewSourceLoader.HasView("Shared\\mypartial.spark")).Return(true);
97+
viewSourceLoader.Expect(x => x.HasView("Home\\mypartial.spark")).Return(false);
98+
viewSourceLoader.Expect(x => x.HasView("Shared\\mypartial.spark")).Return(true);
10099
ExpectGetChunks("Shared\\mypartial.spark", new SendLiteralChunk { Text = "Hello world" });
101100

102-
SetupResult.For(viewSourceLoader.HasView("Home\\_global.spark")).Return(false);
103-
SetupResult.For(viewSourceLoader.HasView("Shared\\_global.spark")).Return(false);
101+
viewSourceLoader.Stub(x => x.HasView("Home\\_global.spark")).Return(false);
102+
viewSourceLoader.Stub(x => x.HasView("Shared\\_global.spark")).Return(false);
104103

105-
mocks.ReplayAll();
106104
loader.Load("Home\\usefile.spark");
107-
mocks.VerifyAll();
105+
viewSourceLoader.VerifyAllExpectations();
106+
syntaxProvider.VerifyAllExpectations();
108107
}
109108

110109
[Test]
111110
public void FindPartialFiles()
112111
{
113-
mocks.ReplayAll();
114112
var partials3 = loader.FindPartialFiles("Home\\other.spark");
115113
var partials2 = loader.FindPartialFiles("Account\\index.spark");
116-
mocks.VerifyAll();
114+
viewSourceLoader.VerifyAllExpectations();
115+
syntaxProvider.VerifyAllExpectations();
117116

118117
Assert.AreEqual(3, partials3.Count);
119118
Assert.That(partials3.Contains("comment"));
@@ -129,30 +128,30 @@ public void FindPartialFiles()
129128
[Test, ExpectedException(typeof(FileNotFoundException))]
130129
public void FileNotFoundException()
131130
{
132-
Expect.Call(viewSourceLoader.GetViewSource("Home\\nosuchfile.spark")).Throw(new FileNotFoundException());
131+
viewSourceLoader.Expect(x => x.GetViewSource("Home\\nosuchfile.spark")).Throw(new FileNotFoundException());
133132

134-
mocks.ReplayAll();
135133
loader.Load("Home\\nosuchfile.spark");
136-
mocks.VerifyAll();
134+
viewSourceLoader.VerifyAllExpectations();
135+
syntaxProvider.VerifyAllExpectations();
137136
}
138137

139138
[Test]
140139
public void ExpiresWhenFilesChange()
141140
{
142141
var source = ExpectGetChunks("home\\changing.spark", new SendLiteralChunk { Text = "Hello world" });
143-
Expect.Call(viewSourceLoader.GetViewSource("home\\changing.spark")).Return(source);
144-
Expect.Call(source.LastModified).Return(0);
145-
Expect.Call(viewSourceLoader.GetViewSource("home\\changing.spark")).Return(source);
146-
Expect.Call(source.LastModified).Return(42);
142+
viewSourceLoader.Expect(x => x.GetViewSource("home\\changing.spark")).Return(source);
143+
source.Expect(x=>x.LastModified).Return(0);
144+
viewSourceLoader.Expect(x => x.GetViewSource("home\\changing.spark")).Return(source);
145+
source.Expect(x=>x.LastModified).Return(42);
147146

148-
SetupResult.For(viewSourceLoader.HasView("home\\_global.spark")).Return(false);
149-
SetupResult.For(viewSourceLoader.HasView("Shared\\_global.spark")).Return(false);
147+
viewSourceLoader.Stub(x => x.HasView("home\\_global.spark")).Return(false);
148+
viewSourceLoader.Stub(x => x.HasView("Shared\\_global.spark")).Return(false);
150149

151-
mocks.ReplayAll();
152150
loader.Load("home\\changing.spark");
153151
Assert.That(loader.IsCurrent());
154152
Assert.That(!loader.IsCurrent());
155-
mocks.VerifyAll();
153+
viewSourceLoader.VerifyAllExpectations();
154+
syntaxProvider.VerifyAllExpectations();
156155
}
157156

158157
[Test]

src/Spark.Web.Mvc.Tests/MvcMockHelpers.cs

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/Spark.Web.Mvc.Tests/Spark.Web.Mvc.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -71,7 +71,6 @@
7171
<Compile Include="Controllers\StubController.cs" />
7272
<Compile Include="DescriptorBuildingTester.cs" />
7373
<Compile Include="Models\Comment.cs" />
74-
<Compile Include="MvcMockHelpers.cs" />
7574
<Compile Include="Properties\AssemblyInfo.cs" />
7675
<Compile Include="SparkBatchCompilerTester.cs" />
7776
<Compile Include="SparkViewFactoryTester.cs" />

0 commit comments

Comments
 (0)