2

So I have a C# application and part of it references the microsoft office interop assemblies. I'd like to gracefully handle the case that the user doesn't have office installed, but to do so, I need to be able to test the case that office is not installed. Short of uninstalling office, or actually uninstalling these assemblies on my machine, is there an easy way to test this? I found the assemblies in C:\Windows\assembly, but it doesn't look like there's an easy way to rename them or move them temporarily (at least not in Windows 7). i.e. Can I fake out my application to believe that these assemblies aren't installed so I can test this code path? Thanks for any help you can provide.

dbromberg
  • 97
  • 8
  • run it on a different computer – Sam I am says Reinstate Monica Mar 21 '12 at 18:38
  • How are you identifying the failure to load the assembly? If you're using the AppDomain's `AssemblyResolve` event, then you could test your code using a mock object that implements `_AppDomain` and raises the event. – phoog Mar 21 '12 at 18:55
  • Sam I am- Not really an option- I need to be able to step through the code. Let's say for arguments sake that I only have one computer. There should really be a way to do this- fake the application into thinking the assembly on my machine isn't there. – dbromberg Mar 21 '12 at 18:55
  • phoog- that was my plan, to use that event, yes. I suppose I could force the application to run the code in that event, but I wanted to be able to test when the load of the assembly actually occurred- during startup? When a function relying on that assembly gets called, etc. – dbromberg Mar 21 '12 at 18:57

1 Answers1

3

Short of uninstalling office, or actually uninstalling these assemblies on my machine, is there an easy way to test this?

Test it on one of your testing vm's ;)

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • Is this the standard way to do this? I don't have any virtual machines set up to test. – dbromberg Mar 21 '12 at 18:47
  • Well, the standard way when something invoes any fom orf setup testing IS using virtual machines. You need to be able to roll back any machine klevel changes anyway. I can not imagine working without having 8 to 16gb of machines available. – TomTom Mar 21 '12 at 18:50