-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add equals method for workplans #316
base: dev
Are you sure you want to change the base?
Add equals method for workplans #316
Conversation
|
} | ||
Workplan newPlan = (Workplan)obj; | ||
|
||
var start = this.Connectors.First(x => x.Name.Equals("Start")); |
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.
You can not do this based on names. This comparison needs to be more generic.
/// </summary> | ||
/// <param name="obj"></param> | ||
/// <returns></returns> | ||
public override bool Equals(object obj) |
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.
Please move this into a static method on Workplan.Equals(workplanA, workplanB)
instead of overwriting the object method.
|
||
if (!(isAlreadyChecked)) | ||
{ | ||
needToCheck.Add(follower); |
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.
Use the workplanstep id instead of collection index here.
- compare the types of steps and connectors - create tests
98e2667
to
28eaa67
Compare
List<IWorkplanStep> needToCheck = new List<IWorkplanStep>(); | ||
List<IWorkplanStep> newNeedToCheck = new List<IWorkplanStep>(); | ||
|
||
List<IWorkplanStep> check = new List<IWorkplanStep>(); |
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.
Maybe checkED
would be a better name
|
||
List<IWorkplanStep> check = new List<IWorkplanStep>(); | ||
|
||
needToCheck.Add(step); |
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.
Can be done together with the initialization `new List() {step};
{ | ||
|
||
|
||
for (int a = 0; a < step.Outputs.Length; a++) |
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.
This could be put in a separate method. You method is too long and unclear
var follower = this.Steps.FirstOrDefault(x => x.Inputs.Any(y => y.Equals(connector))); | ||
var newFollower = newPlan.Steps.FirstOrDefault(x => x.Inputs.Any(y => y.Equals(newConnector))); | ||
|
||
bool isAlreadyChecked = (check.Contains(follower) || check.Contains(newFollower)); |
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.
Why are you checking if newFollower
is in check
, when you only add steps of your current workplan to check
?
{ | ||
var follower = this.Steps.FirstOrDefault(x => x.Inputs.Any(y => y.Equals(connector))); | ||
var newFollower = newPlan.Steps.FirstOrDefault(x => x.Inputs.Any(y => y.Equals(newConnector))); | ||
|
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.
Why don't you check, if the outputs are the same?
@@ -14,6 +14,7 @@ | |||
</ItemGroup> | |||
|
|||
<ItemGroup> | |||
<ProjectReference Include="..\..\Moryx.AbstractionLayer\Moryx.AbstractionLayer.csproj" /> |
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.
Is that fine or should the test move to Moryx.AbstractionLayer.Tests
@1nf0rmagician ?
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.
Either that or alternatively the test could be limited to IWorkplanStep
and reflection.
[ActivityResults(typeof(DefaultActivityResult))] | ||
public class AssemblingActivity : Activity<AssemblingParameters> | ||
{ | ||
|
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.
Remove Empty lines
using Moryx.AbstractionLayer; | ||
using Moryx.AbstractionLayer.Capabilities; | ||
using System; | ||
using System.Collections.Generic; |
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.
Check if all usings are needed
private Workplan fifthWorkplan; | ||
private Workplan sixthWorkplan; | ||
|
||
public Workplan CreateFirstWorkplan() |
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.
Quite a lot of duplicated code in the workplan creation
[TestFixture] | ||
public class EqualTest | ||
{ | ||
private Workplan firstWorkplan; |
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.
Maybe better names. What are the differences between each workplan?
/// <param name="obj"></param> | ||
/// <returns></returns> | ||
public override bool Equals(object obj) | ||
public static bool noteSameFollowringSteps(Workplan workplan, Workplan newWorkplan ,IWorkplanStep step, IWorkplanStep newStep, List<IWorkplanStep> needToCheck, List<IWorkplanStep> newNeedToCheck, List<IWorkplanStep> isChecked) |
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.
Name is confusing. Methodnames are always written in PascalCase
using System.Linq; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.ComTypes; |
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.
What do you need this for?
- create an additional method to check connactions and following steps - reduce unnecessary variables - changing the sequence - rename methods in the EqualTest class - switch from a override method to a static method
8aadc89
to
2742aa4
Compare
still missing:
feature for the ticket #242