Mock RevitAPI

Mock RevitAPI

Anonymous
Not applicable
1,323 Views
5 Replies
Message 1 of 6

Mock RevitAPI

Anonymous
Not applicable

Hi!

 

I bet this question has been raised a bunch of times before, but this is an important matter (to me).

 

Q: Why does RevitAPI.dll require Revit to run? Will it ever be possible to mock the API?

 

Reason: I want do write API-dependent code in a modern way using TDD. Of course the test should be able to run outside of Revit, so it will require mocking of the API.

 

This is easy to do when programming towards Tekla or CSi software (what i worked with in my previous job).

 

 

Regards,

Eirik Aasved Holst

0 Likes
1,324 Views
5 Replies
Replies (5)
Message 2 of 6

Charles.Piro
Advisor
Advisor
0 Likes
Message 3 of 6

Anonymous
Not applicable

Thank you, Charles.

 

The post you refer to discuss how to access data in revit-files outside of Revit (which is really interesting, and i've actually written a method that extracts all metadata from out family library, uploads it to a database which is queryable from a Revit plugin).

 

I startet this post because I'm interrested in mocking/faking RevitAPI.dll within an IDE (Visual Studio), enabling a test driven development process (and also: Continuous Integration; building and running tests in the cloud each time i commit code)

 

 

 

Regards,

Eirik Aasved Holst

0 Likes
Message 4 of 6

Charles.Piro
Advisor
Advisor

Sorry,

 

but I don't interstand that you want.

In visual Studio, you can debug with Revit, but you want test your code without running Revit ?

 

To test different lines of code, I use macros in Revit. It's quick and easy for test different methods and view result immediately .

 

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 5 of 6

Anonymous
Not applicable

Charles, 

 

"you want test your code without running Revit ?" -Correct. That is exaclty what I want. And to be honest, it is rather crucial for efficient coding and ensuring high quality of the code.

 

Visual Studio Enterprise provides the opportunity of creating fake assemblies of refered dlls (see pics). This should enable unit testing of API-dependentg code, if RevitAPI.dll did not require Revit to run. When i try to run a simple test, it throws an exception.

 

 

2016-05-20_13-40-20.jpg

 

 

2016-05-20_13-46-44.jpg

Message 6 of 6

Anonymous
Not applicable
0 Likes