Not very elegant, but you could decorate it and use your decorator in place of StackReference in your Pulumi code, then have the decorator check a "Mocking" static property at run time to see whether to use "real" StackReference or some other static properties. Your unit test code could set the static properties and set "Mocking" to true on your decorator. Similarly for pulumi.config.