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
18 using System
.Collections
;
20 using NUnit
.Framework
;
23 /// Summary description for GetPropertyTestCase.
25 [TestFixture
] public class GetPropertyTestCase
27 private const String SVN_MIME_TYPE
= "svn:mime-type";
29 private const String NO_PROPS_PATH
= "noprops";
30 private const String MIME_PROP_PATH
= "mime";
31 private const String EOL_STYLE_PROP_PATH
= "eol";
32 private const String LOGREGEGX_PROP_PATH
= "logregex";
34 private IRepository repository
;
36 #region Setup / Teardown
38 [TestFixtureSetUp
] public void FixtureSetUp()
40 MockRepository mockRepository
= new MockRepository();
41 mockRepository
.AddFile(NO_PROPS_PATH
, null, null, null);
42 mockRepository
.AddFile(MIME_PROP_PATH
, null, Props("svn:mime-type", "text/source"), null);
43 mockRepository
.AddFile(EOL_STYLE_PROP_PATH
, null, Props("svn:eol-style", "native"), null);
44 mockRepository
.AddFile(LOGREGEGX_PROP_PATH
, null, Props("bugtraq:logregex", @"^.*$", @"\d+"), null);
46 repository
= mockRepository
;
50 private static IDictionary
Props(String property
, params String
[] values
)
52 IDictionary dictionary
= new Hashtable();
53 dictionary
.Add(property
, values
);
61 [Test
] public void NoProps()
63 RepositoryFile file
= new RepositoryFile(repository
, NO_PROPS_PATH
, RepositoryStatus
.Unchanged
, RepositoryStatus
.Unchanged
);
65 Assert
.IsNull(file
.GetProperty("svn:mime-type"));
69 [Test
] public void MimeProps()
71 RepositoryFile file
= new RepositoryFile(repository
, MIME_PROP_PATH
, RepositoryStatus
.Unchanged
, RepositoryStatus
.Unchanged
);
73 String
[] props
= file
.GetProperty("svn:mime-type");
74 Assert
.AreEqual(1, props
.Length
);
75 Assert
.AreEqual("text/source", props
[0]);
76 Assert
.AreEqual("text/source", file
.MimeType
);
80 [Test
] public void EolStyleProps()
82 RepositoryFile file
= new RepositoryFile(repository
, EOL_STYLE_PROP_PATH
, RepositoryStatus
.Unchanged
, RepositoryStatus
.Unchanged
);
84 String
[] props
= file
.GetProperty("svn:eol-style");
85 Assert
.AreEqual(1, props
.Length
);
86 Assert
.AreEqual("native", props
[0]);
89 [Test
] public void LogRegexProps()
91 RepositoryFile file
= new RepositoryFile(repository
, LOGREGEGX_PROP_PATH
, RepositoryStatus
.Unchanged
, RepositoryStatus
.Unchanged
);
93 String
[] props
= file
.GetProperty("bugtraq:logregex");
94 Assert
.AreEqual(2, props
.Length
);
95 Assert
.AreEqual(@"^.*$", props
[0]);
96 Assert
.AreEqual(@"\d+", props
[1]);
101 [ExpectedException(typeof(ArgumentNullException
))]
102 [Test
] public void GetPropertyWithNullName()
104 RepositoryFile file
= new RepositoryFile(repository
, NO_PROPS_PATH
, RepositoryStatus
.Unchanged
, RepositoryStatus
.Unchanged
);
106 file
.GetProperty(null);