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

D39652_Mock Data Expression Fixed #3926

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Ginger/GingerCoreNET/RosLynLib/CodeProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public static string GetBogusExpressionEvaluteResult(string expression, out stri
{
evalresult = string.Join(",", (int[])result);
}
else if (result.GetType() == typeof(string[]))
{
evalresult = string.Join(",", (string[])result);
}
Comment on lines +385 to +388
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

No existing tests found for CodeProcessor. Consider creating a new test file.

There are currently no unit tests for the GetBogusExpressionEvaluteResult method. Please create a new test file and add a test case to cover the string[] result scenario to ensure the new functionality is properly validated.

Analysis chain

Overall improvement in mock data handling. Consider adding a test case.

This change enhances the GetBogusExpressionEvaluteResult method by adding support for string[] results. It's a valuable addition that aligns well with the PR's objective of fixing mock data expressions.

To ensure the new functionality works as expected, consider adding a unit test that covers this scenario. Here's a shell script to check for existing tests and suggest where to add a new one:

This script will help identify existing test files and Bogus-related test data, guiding you on where to add a new test case for the string[] result scenario.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing tests and suggest where to add a new one

# Find test files related to CodeProcessor
test_files=$(fd --type f --extension cs CodeProcessorTests)

if [ -z "$test_files" ]; then
  echo "No existing test files found for CodeProcessor. Consider creating a new test file."
else
  echo "Existing test files for CodeProcessor:"
  echo "$test_files"
  echo "Consider adding a new test case in one of these files to cover the string[] result scenario in GetBogusExpressionEvaluteResult method."
fi

# Check for Bogus-related test data or mock generators
bogus_test_data=$(rg --type cs "new Bogus\.Faker<" --files-with-matches)

if [ -n "$bogus_test_data" ]; then
  echo "Files with Bogus test data generators:"
  echo "$bogus_test_data"
  echo "You might want to use or extend these for your new test case."
fi

Length of output: 345

else
{
evalresult = result.ToString();
Expand Down
9 changes: 9 additions & 0 deletions Ginger/GingerCoreNETUnitTest/RosLynTestLib/GlobalsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public void TestBogusData_AddressfullAddress_IsNotnullAndEmpty()
Assert.IsTrue(output != null && !output.Equals(string.Empty));
}

[TestMethod]
public void TestBogusData_AddressCountryCode_IsNotnullAndEmpty()
{
string Expression = "{MockDataExp Fun=Address(@\"en\").CountryCode();}";
string error = string.Empty;
string output = CodeProcessor.GetBogusDataGenerateresult(Expression);
Assert.IsTrue(output != null && !output.Equals(string.Empty));
}

[TestMethod]
public void PastDate_FetchPastDateOnly_IsNotnullAndEmpty()
{
Expand Down
Loading