Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Experiments / SubversionHooks / Hooks.Tests / MockRepository.cs
bloba37c007c9ed52d601b9670eeff70c3108f8264a6
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
17 using System;
18 using System.Collections;
19 using System.Text;
21 using Castle.SvnHooks;
23 /// <summary>
24 /// Summary description for MockRepository.
25 /// </summary>
26 public class MockRepository : IRepository
28 public MockRepository()
32 public void AddFile(String path, String author, IDictionary properties, String contents)
34 byte[] byteContents = null;
35 if (contents != null)
37 byteContents = Encoding.ASCII.GetBytes(contents);
40 Files.Add(path, new File(path, author, properties, byteContents));
43 #region IRepository Members
45 public string[] GetProperty(string path, string property)
47 File file = Files[path] as File;
48 if (file == null || file.Properties == null)
49 return null;
51 return (String[])file.Properties[property];
54 public System.IO.Stream GetFileContents(string path)
56 File file = Files[path] as File;
57 if (file == null || file.Contents == null)
58 return null;
60 return new System.IO.MemoryStream(file.Contents, false);
64 #endregion
66 private readonly IDictionary Files = new Hashtable();
68 private class File
70 public File(String path, String author, IDictionary properties, byte[] contents)
72 this.properties = properties;
73 this.contents = contents;
76 public IDictionary Properties
78 get { return properties; }
80 public byte[] Contents
82 get { return contents; }
85 private IDictionary properties;
86 private byte[] contents;