-
Notifications
You must be signed in to change notification settings - Fork 60
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
FIxed issue with Entity Equality #4025
Merged
Maheshkale447
merged 2 commits into
Releases/Official-Release
from
Feature/EntityEquality
Dec 9, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
Ginger/GingerCoreCommonTest/EqualityTests/ActivityTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using Amdocs.Ginger.Repository; | ||
using GingerCore; | ||
using GingerCore.Actions; | ||
using GingerCore.Variables; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GingerCoreCommonTest.Repository; | ||
[TestClass] | ||
public class ActivityEqualityTests | ||
{ | ||
[TestMethod] | ||
public void AreEqual_SameProperties_ReturnsTrue() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity | ||
{ | ||
ActivityName = "Search and Buy iPhone 15 Device", | ||
TargetApplication = "Brain_3UK_Self Service", | ||
Type = eSharedItemType.Regular, | ||
ActivitiesGroupID = null, | ||
Acts = [new ActDummy()], | ||
Variables = [new VariableString()] | ||
}; | ||
|
||
var activity2 = new Activity | ||
{ | ||
ActivityName = "Search and Buy iPhone 15 Device", | ||
TargetApplication = "Brain_3UK_Self Service", | ||
Type = eSharedItemType.Regular, | ||
ActivitiesGroupID = null, | ||
Acts = [new ActDummy()], | ||
Variables = [new VariableString()] | ||
}; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsTrue(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentActivityName_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { ActivityName = "TestActivity1" }; | ||
var activity2 = new Activity { ActivityName = "TestActivity2" }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentTargetApplication_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { TargetApplication = "TestApp1" }; | ||
var activity2 = new Activity { TargetApplication = "TestApp2" }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentType_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { Type = eSharedItemType.Regular }; | ||
var activity2 = new Activity { Type = eSharedItemType.Link }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentActivitiesGroupID_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { ActivitiesGroupID = "Group1" }; | ||
var activity2 = new Activity { ActivitiesGroupID = "Group2" }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentActsCount_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { Acts = [new ActDummy()] }; | ||
var activity2 = new Activity { Acts = [new ActDummy(), new ActDummy()] }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
[TestMethod] | ||
public void AreEqual_DifferentVariablesCount_ReturnsFalse() | ||
{ | ||
// Arrange | ||
var activity1 = new Activity { Variables = [new VariableString()] }; | ||
var activity2 = new Activity { Variables = [new VariableString(), new VariableString()] }; | ||
|
||
// Act | ||
var result = activity1.AreEqual(activity2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Ginger/GingerCoreCommonTest/EqualityTests/BusinessFlowTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using GingerCore; | ||
using GingerCore.Platforms; | ||
using GingerCore.Variables; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
|
||
namespace GingerCoreCommonTest.Repository | ||
{ | ||
[TestClass] | ||
public class BusinessFlowEqualityTests | ||
{ | ||
[TestMethod] | ||
public void ArAeEqual_ShouldReturnTrue_WhenBusinessFlowsAreEqual() | ||
{ | ||
// Arrange | ||
var businessFlow1 = CreateBusinessFlow("TestFlow"); | ||
var businessFlow2 = CreateBusinessFlow("TestFlow"); | ||
|
||
// Act | ||
var result = businessFlow1.AreEqual(businessFlow2); | ||
|
||
// Assert | ||
Assert.IsTrue(result); | ||
} | ||
Comment on lines
+12
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance test coverage for BusinessFlow equality The current tests only verify equality based on the
Example test cases to add: [TestMethod]
public void AreEqual_DifferentActivityOrder_ReturnsTrue()
{
// Arrange
var flow1 = CreateBusinessFlow("TestFlow");
var flow2 = CreateBusinessFlow("TestFlow");
flow2.Activities.Reverse();
// Act
var result = flow1.AreEqual(flow2);
// Assert
Assert.IsTrue(result);
}
[TestMethod]
public void AreEqual_NullActivities_ReturnsFalse()
{
// Arrange
var flow1 = CreateBusinessFlow("TestFlow");
var flow2 = CreateBusinessFlow("TestFlow");
flow2.Activities = null;
// Act
var result = flow1.AreEqual(flow2);
// Assert
Assert.IsFalse(result);
} Also applies to: 26-38 |
||
|
||
[TestMethod] | ||
public void ArAeEqual_ShouldReturnFalse_WhenBusinessFlowsAreNotEqual() | ||
{ | ||
// Arrange | ||
var businessFlow1 = CreateBusinessFlow("TestFlow1"); | ||
var businessFlow2 = CreateBusinessFlow("TestFlow2"); | ||
|
||
// Act | ||
var result = businessFlow1.AreEqual(businessFlow2); | ||
|
||
// Assert | ||
Assert.IsFalse(result); | ||
} | ||
|
||
private BusinessFlow CreateBusinessFlow(string name) | ||
{ | ||
return new BusinessFlow | ||
{ | ||
Name = name, | ||
Activities = | ||
[ | ||
new Activity { ActivityName = "Activity1" }, | ||
new Activity { ActivityName = "Activity2" } | ||
], | ||
Variables = | ||
[ | ||
new VariableString { Name = "Variable1" }, | ||
new VariableString { Name = "Variable2" } | ||
], | ||
TargetApplications = | ||
[ | ||
new TargetApplication { AppName = "Target1", Guid = Guid.NewGuid() }, | ||
new TargetApplication { AppName = "Target2", Guid = Guid.NewGuid() } | ||
] | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance collection equality tests
The current tests only verify collection counts. Consider adding tests for:
Example:
Also applies to: 112-124