1 //***************************************************************************
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.
10 //***************************************************************************
14 using Microsoft
.VisualStudio
.Shell
;
16 namespace Microsoft
.VisualStudio
.Shell
.RegistrationAttributes
.UnitTests
19 /// Helper code to create RegistrationContext mock
21 public class MockRegistrationContext
: RegistrationAttribute
.RegistrationContext
, IDisposable
23 StreamWriter streamWriter
;
24 public override string ComponentPath
29 public override string CodeBase
34 public override Type ComponentType
36 get { return (new Int32()).GetType(); }
39 public override string InprocServerPath
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();
63 public override string EscapePath(string str
)
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
82 /// IDisposable interface implementation to dispose StreamWriter member that it owns
87 GC
.SuppressFinalize(this);
92 /// IDisposable pattern Implementation
94 /// <param name="disposing"></param>
95 private void Dispose(bool disposing
)
99 if (streamWriter
!= null)
101 streamWriter
.Dispose();
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() { ; }