Refactored the Kernel registration fluent interface to be more readable, better suppo...
[castle.git] / Experiments / SubversionHooks / Hooks.Tests / RepositoryFileTestCases / PerformanceTestCase.cs
blob50ea022e4c9dd21cf0e90eec817ac46e9f3db522
1 // Copyright 2004-2008 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.
15 namespace Castle.SvnHooks.Tests.RepositoryFileTestCases
17 using System;
19 using NUnit.Framework;
21 using Castle.SvnHooks;
23 /// <summary>
24 /// This test case ensures that the RepositoryFile
25 /// does not call the IRepository functions excessively,
26 /// this is to allow for speedier processing of the
27 /// hooks since unnecessary calls will not be made.
28 /// </summary>
29 [TestFixture] public class PerformanceTestCase : IRepository
32 private RepositoryFile file;
33 private int count;
35 #region Setup / Teardown
37 [SetUp] public void SetUp()
39 count = 0; // this line has to be before the RepositoryFile line
40 file = new RepositoryFile(this, "file", RepositoryStatus.Unchanged, RepositoryStatus.Unchanged);
44 #endregion
46 #region IRepository Members
48 public string[] GetProperty(string path, string property)
50 count++;
51 return new String[]{"property"};
54 public System.IO.Stream GetFileContents(string path)
56 count++;
57 return null;
61 #endregion
63 /// <summary>
64 /// This test simply ensures that the
65 /// constructor for RepositoryFile never
66 /// calls the IRepository, the information
67 /// should be collected on-demand, not on
68 /// initialization.
69 /// </summary>
70 [Test] public void Constructor()
72 Assert.AreEqual(0, count, "RespositoryFile's constructor calls the repository");
75 [Test] public void MimeType()
77 String ether = file.MimeType;
78 ether = file.MimeType;
80 Assert.AreEqual(1, count, "RepositoryFile.MimeType called the repository more than once");
83 [Test] public void IsText()
85 bool ether = file.IsText;
86 ether = file.IsText;
88 Assert.AreEqual(1, count, "RepositoryFile.IsText called the repository more than once");