Using Assets in Multiple Projects

In Silk4NET, image assets, image verifications, and object maps are referred to as assets. If you want to use assets outside of the scope of the project in which they are located, you need to add a direct project reference from the project in which you want to use the assets to the project in which the assets are located.

During replay, when an asset is used, Silk4NET firstly searches in the current project for the asset. The current project is the directory which contains the test code that is currently executed. If Silk4NET does not find the asset in the current project, Silk4NET additionally searches the projects to which the current project has a project reference. If the asset is still not found, Silk4NET throws an error.

Note: When the code of a project, which you have added as a dependency to another project, is not referenced in the code of the dependent project, Visual Studio will remove the project dependency when you build the dependent project. To use assets that are located in a project dependency, you have to add a code reference from the dependent project to a member of the project in which the assets are located. By adding such a code reference, you ensure that Visual Studio will not remove the project dependency when you are building the dependent project. For example, you could add a class or a constant to the project dependency, and then call the class or constant in the code of the dependent project.

If assets with the same name exist in more than one project, and you do not want to use the asset that is included in the current project, you can define which specific asset you want to use in any method that uses the asset. To define which asset you want to use, add the assembly name as a prefix to the asset name when calling the method. The assembly name defaults to the project name.

Example: Adding a project reference

If the project ProjectA contains a test that calls the following code:
'VB code
window.ImageClick("imageAsset")
and the image asset imageAsset is located in project ProjectB, you need to add a direct project reference from ProjectA to ProjectB.

Example: Calling a specific asset

If ProjectA and ProjectB both contain an image asset with the name anotherImageAsset, and you explicitly want to click the image asset from ProjectB, use the following code:
'VB code
window.ImageClick("ProjectB:anotherImageAsset")