optimizely / csharp-sdk

.NET based C# SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/csharp-sdk
Apache License 2.0
19 stars 20 forks source link

Add support for unit testing for user context #271

Closed daniel-pons closed 3 years ago

daniel-pons commented 3 years ago

Summary

The following versions of Optimizely C# SDK would use the methods defined on the class OptimizelyUserContext to perform some processes, E.G: Decide, TrackEvent, DecideAll, etc...

Them, it is required on the vast majority of unit testing frameworks for mocking this object to have an interface for it.

This PR creates the interface IOptimizelyUserContext for doing so.

Also fixes a problem with development environments with a culture different from english.

msohailhussain commented 3 years ago

Thanks Daniel. Can you please sign this CLA and update this branch, so we can review & merge this PR? https://docs.google.com/forms/d/e/1FAIpQLSf9cbouWptIpMgukAKZZOIAhafvjFCV8hS00XJLWQnWDFtwtA/viewform

daniel-pons commented 3 years ago

Thanks Daniel. Can you please sign this CLA and update this branch, so we can review & merge this PR? https://docs.google.com/forms/d/e/1FAIpQLSf9cbouWptIpMgukAKZZOIAhafvjFCV8hS00XJLWQnWDFtwtA/viewform

Thanks Daniel. Can you please sign this CLA and update this branch, so we can review & merge this PR? https://docs.google.com/forms/d/e/1FAIpQLSf9cbouWptIpMgukAKZZOIAhafvjFCV8hS00XJLWQnWDFtwtA/viewform

Hi, I already did before creating PR. probably I'm around your records

daniel-pons commented 3 years ago

please address comments.

I think I fixed what was requested. However I'm getting some kind of error when running the integration tests. The command "mkdir $HOME/travisci-tools && pushd $HOME/travisci-tools && git init && git pull https://$CI_USER_TOKEN@github.com/optimizely/travisci-tools.git && popd" failed and exited with 1 during .

Many thanks.

msohailhussain commented 3 years ago

me kind of error when running the integration tests.

Thanks I will take care of it CI stuff.

msohailhussain commented 3 years ago

@daniel-pons I tested your changes but that code will break existing code, can you please revert those. I have pointed out as well. In CreateUserContext, should return OptimizelyUserContext and UserContext in OptimizelyDecisions should be OptimizelyUserContext not an interface.

daniel-pons commented 3 years ago

I created the PR with the virtual keyword. It's here: https://github.com/optimizely/csharp-sdk/pull/280

It also includes the fix for unit tests running on non English systems.

I'll then, close this PR.

Many thanks!.