Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot mock IUpdateEntityRequestBuilder<TEntity> #262

Open
baynezy opened this issue Feb 24, 2025 · 2 comments · May be fixed by #264
Open

Cannot mock IUpdateEntityRequestBuilder<TEntity> #262

baynezy opened this issue Feb 24, 2025 · 2 comments · May be fixed by #264

Comments

@baynezy
Copy link

baynezy commented Feb 24, 2025

I am trying to mock an UpdateItem<TEntity> to unit test my code. I am following the approach you use in this example. However, it gets very bent out of shape with IUpdateEntityRequestBuilder<TEntity>.

Example

var builderMock = Substitute.For<IUpdateEntityRequestBuilder<object>>();

I get an error:

System.TypeLoadException
Method 'Create' in type 'Castle.Proxies.ObjectProxy_2' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Which I have also raised on the NSubstiture repo. nsubstitute/NSubstitute#866 I have tried the same thing with Moq and I get the same issue. So it is likely a Castle.Core + EfficientDynamoDb compatibility issue.

In this comment @firenero states that:

EfficientDynamoDb calls are mockable by design

Is this still the case? Am I doing something wrong?

@firenero
Copy link
Contributor

firenero commented Mar 1, 2025

Thanks for reporting it @baynezy. The issue happens because of the internal method in IUpdateEntityRequestBuilder. We should add default implementation to this method similarly to IGetItemEntityRequestBuilder/ITableBuilder. It also makes sense to verify that other interfaces are not affected by similar issues and address all of them in a single PR.

I think I can look into it in the next few days. Or you can submit a PR if you want to get this change merged faster.

@baynezy
Copy link
Author

baynezy commented Mar 5, 2025

Thanks @firenero - I see you have begun this work. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants