added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / RegistrationAttributes / UnitTests / Tests / MockRegistrationContext.cs
blob7cfe9bd64946f83c58a14cc2195685aec346d7c3
1 //***************************************************************************
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // This code is licensed under the Visual Studio SDK license terms.
5 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 //
10 //***************************************************************************
12 using System;
13 using System.IO;
14 using Microsoft.VisualStudio.Shell;
16 namespace Microsoft.VisualStudio.Shell.RegistrationAttributes.UnitTests
18 /// <summary>
19 /// Helper code to create RegistrationContext mock
20 /// </summary>
21 public class MockRegistrationContext : RegistrationAttribute.RegistrationContext, IDisposable
23 StreamWriter streamWriter;
24 public override string ComponentPath
26 get { return "tt"; }
29 public override string CodeBase
31 get { return "tt"; }
34 public override Type ComponentType
36 get { return (new Int32()).GetType(); }
39 public override string InprocServerPath
41 get { return "tt"; }
44 public override string RootFolder
46 get { throw new NotImplementedException("The method or operation is not implemented."); }
48 public override RegistrationMethod RegistrationMethod
50 get { return new RegistrationMethod(); }
52 public override TextWriter Log
55 get { String writer = "C:\\21.txt"; streamWriter = new StreamWriter(writer); return streamWriter; }
58 public override RegistrationAttribute.Key CreateKey(string name)
60 MockKey key = new MockKey();
61 return key;
63 public override string EscapePath(string str)
65 return "EscapePath";
67 public override void RemoveKey(string name)
71 public override void RemoveKeyIfEmpty(string name)
75 public override void RemoveValue(string keyname, string valuename)
80 #region IDisposable Members
81 /// <summary>
82 /// IDisposable interface implementation to dispose StreamWriter member that it owns
83 /// </summary>
84 public void Dispose()
86 Dispose(true);
87 GC.SuppressFinalize(this);
89 #endregion
91 /// <summary>
92 /// IDisposable pattern Implementation
93 /// </summary>
94 /// <param name="disposing"></param>
95 private void Dispose(bool disposing)
97 if (disposing)
99 if (streamWriter != null)
101 streamWriter.Dispose();
102 streamWriter = null;
108 internal class MockKey : RegistrationAttribute.Key
110 public override RegistrationAttribute.Key CreateSubkey(String value) { return null; }
111 public override void SetValue(String value, Object objectValue) { ; }
112 public override void Close() { ; }