hello, so currently I only have an endpoint that d...
# pact-net
s
hello, so currently I only have an endpoint that does a GET request (and uses hardcoded data, no repository) so I was wondering how exactly i would implement provider states, since all examples use a repository. Should I make a test repository perhaps, since it would help consumers in the future, if I implement provider states?
m
since all examples use a repository
they do that because they are examples that have a CRUD database. Whatever the repository equivalent is you should implement in your state handlers. If the state involved stubbing a 3rd party API, do that. If it involves stubbing a database, you could inject data into the database or replace it with a stub. The provider state is orthogonal to implementation (by design). Consumers need not know the implementation detail of the provider (information hiding). So do whatever is most natural in the provider code base (I prefer stubbing, FWIW)
s
Great thanks! yeah I think I'd prefer to stub my database then
👍 1
chatgpt is telling me that for a GET request, i have to modify the code to this since I'm doing a GET request:
if (context.Request.Method == HttpMethod.Get.Method)
{
// ... (handle GET request provider states)
}
is this true? i cant get my test to verify
m
Sorry, Chat GPT is so unreliable for code you won’t find any help/support from me on it. I’ve seen examples where it smashes multiple examples together that look sensible, but actually don’t make sense if you look at the API
👍 1
I also don’t know .NET, so won’t comment on an AI generated suggested for a language I don’t understand. Best talking to devs on your team that know .NET
y
ChatGPT’s dataset is also old, and therefore wouldn’t be up to date with the latest Pact documentation, so you will get a best guess (which will more than likely be incorrect)
That actually carries true with older Pact code. It will tell you a convincing lie