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 environment variables that used in plugins #156

Closed
Ram-Rockkzz opened this issue Jul 9, 2024 · 5 comments
Closed

cannot mock environment variables that used in plugins #156

Ram-Rockkzz opened this issue Jul 9, 2024 · 5 comments
Labels
question Further information is requested

Comments

@Ram-Rockkzz
Copy link

Ram-Rockkzz commented Jul 9, 2024

We have env variables to get some confi. We could not create a mocked entity for environment variables while unit testing with fake xrm and it is saying service doesnt have them. Suggest me some help on how to test

@jordimontana82
Copy link
Contributor

jordimontana82 commented Jul 16, 2024

Hi @Ram-Rockkzz ,

It would be best if you could please provide some sample code to see how you are accessing these environment variables. If there a chance you could provide said sample please?

@jordimontana82 jordimontana82 added the question Further information is requested label Jul 16, 2024
@SarviH
Copy link

SarviH commented Aug 29, 2024

I tried environment variables for Dynamics 365 and it's working pretty fine please let us know if it's the same case for you
here is my sample of creating environmentVariable in a testmethod

string jsonEnvironmentVariableVal = "[ { \"applicationUser\":\"test-testuser\", \"applicationUserId\":\"93a4a23f-3ae3-eb11-bacb-0022486d8624\" }]";

var environmentVariableValue = new Entity("environmentvariablevalue");

environmentVariableValue.Id = Guid.NewGuid();

environmentVariableValue.Attributes.Add("value", jsonEnvironmentVariableVal);

environmentVariableValue.Attributes.Add("environmentvariabledefinitionid", new EntityReference("environmentvariabledefinition", Guid.Parse("75cf97bf-daf6-eb11-bacb-000d3a09eec4")));

//Create environment variable value

_service.Create(environmentVariableValue);

//Create dump environment variable definition

var environmentVariableDefinition = new Entity("environmentvariabledefinition");

environmentVariableDefinition.Id = Guid.Parse("75cf97bf-daf6-eb11-bacb-000d3a09eec4");

environmentVariableDefinition.Attributes.Add("schemaname", "testSchemaName");

//Create environment variable

_service.Create(environmentVariableDefinition);

@jordimontana82
Copy link
Contributor

jordimontana82 commented Aug 29, 2024

Thanks a mill @SarviH for your feedback.

@Ram-Rockkzz can you please elaborate on where you have issues? If @SarviH 's sample is not working for you please post a sample unit test that we can use to reproduce your particular scenario.

@Ram-Rockkzz
Copy link
Author

Ram-Rockkzz commented Aug 29, 2024 via email

@jordimontana82
Copy link
Contributor

Ok makes sense @Ram-Rockkzz . Closing this issue so.

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

No branches or pull requests

3 participants