1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
19 using NUnit
.Framework
;
21 using Castle
.SvnHooks
;
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.
29 [TestFixture
] public class PerformanceTestCase
: IRepository
32 private RepositoryFile file
;
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
);
46 #region IRepository Members
48 public string[] GetProperty(string path
, string property
)
51 return new String
[]{"property"}
;
54 public System
.IO
.Stream
GetFileContents(string path
)
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
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
;
88 Assert
.AreEqual(1, count
, "RepositoryFile.IsText called the repository more than once");