- 
                Notifications
    You must be signed in to change notification settings 
- Fork 24
Add equals method for workplans #316
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
          
     Draft
      
      
            marierin
  wants to merge
  3
  commits into
  PHOENIXCONTACT:dev
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
marierin:feature/addEqualsMethodForWorkplans
  
      
      
   
  
    
  
  
  
 
  
      
    base: dev
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            3 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 hidden or 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,18 @@ | ||
| using Moryx.Workplans; | ||
| using System.Collections.Generic; | ||
|  | ||
| namespace Moryx.Workflows.Implementation | ||
| { | ||
| public class ComparingProperties | ||
| { | ||
| public IWorkplanStep Step { get; set;} | ||
| public IWorkplanStep NewStep { get; set; } | ||
| public Workplan Workplan { get; set; } | ||
| public Workplan NewWorkplan { get; set; } | ||
| public List<IWorkplanStep> IsChecked { get; set; } | ||
| public List<IWorkplanStep> NeedToCheck { get; set; } | ||
| public List<IWorkplanStep> NewNeedToCheck { get; set; } | ||
| } | ||
|  | ||
| } | ||
|  | 
  
    
      This file contains hidden or 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 hidden or 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
    
  
  
    
              
              
        
          
          
            23 changes: 23 additions & 0 deletions
          
          23 
        
  src/Tests/Moryx.Tests/Workplans/Dummies/AssemblingActivity.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,23 @@ | ||
| using Moryx.AbstractionLayer; | ||
| using Moryx.AbstractionLayer.Capabilities; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
| [ActivityResults(typeof(DefaultActivityResult))] | ||
| public class AssemblingActivity : Activity<AssemblingParameters> | ||
| { | ||
| public override ProcessRequirement ProcessRequirement => ProcessRequirement.NotRequired; | ||
|  | ||
| public override ICapabilities RequiredCapabilities => new AssemblingCapabilities(); | ||
|  | ||
| protected override ActivityResult CreateResult(long resultNumber) | ||
| { | ||
| return ActivityResult.Create((DefaultActivityResult)resultNumber); | ||
| } | ||
|  | ||
| protected override ActivityResult CreateFailureResult() | ||
| { | ||
| return ActivityResult.Create(DefaultActivityResult.Failed); | ||
| } | ||
| } | ||
| } | 
        
          
          
            23 changes: 23 additions & 0 deletions
          
          23 
        
  src/Tests/Moryx.Tests/Workplans/Dummies/AssemblingCapabilities.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,23 @@ | ||
| using Moryx.AbstractionLayer.Capabilities; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
|  | ||
| public class AssemblingCapabilities : CapabilitiesBase | ||
| { | ||
| public int Value { get; set; } | ||
|  | ||
| protected override bool ProvidedBy(ICapabilities provided) | ||
| { | ||
| var providedAssembling = provided as AssemblingCapabilities; | ||
| if (providedAssembling == null) | ||
| return false; | ||
|  | ||
| if (providedAssembling.Value < Value) // Provided must be greater or equal | ||
| return false; | ||
|  | ||
| return true; | ||
| } | ||
| } | ||
|  | ||
| } | 
        
          
          
            17 changes: 17 additions & 0 deletions
          
          17 
        
  src/Tests/Moryx.Tests/Workplans/Dummies/AssemblingParameters.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,17 @@ | ||
| using Moryx.AbstractionLayer; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
| public class AssemblingParameters : Parameters | ||
| { | ||
| protected override void Populate(IProcess process, Parameters instance) | ||
| { | ||
|  | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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,16 @@ | ||
| using Moryx.AbstractionLayer; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Xml.Linq; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
| [Display(Name = "Assembling Task", Description = "Task which does something with a product")] | ||
| public class AssemblingTask : TaskStep<AssemblingActivity, AssemblingParameters> | ||
| { | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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,16 @@ | ||
| using Moryx.AbstractionLayer; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Xml.Linq; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
| [Display(Name = "PackagingTask", Description = "Task which does something with a product")] | ||
| public class ColorizingTask : TaskStep<AssemblingActivity, AssemblingParameters> | ||
| { | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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,16 @@ | ||
| using Moryx.AbstractionLayer; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Xml.Linq; | ||
|  | ||
| namespace Moryx.Tests.Workplans.Dummies | ||
| { | ||
| [Display(Name = "PackagingTask", Description = "Task which does something with a product")] | ||
| public class PackagingTask : TaskStep<AssemblingActivity, AssemblingParameters> | ||
| { | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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,127 @@ | ||
| using Moryx.Workplans; | ||
| using Moryx.AbstractionLayer; | ||
| using NUnit.Framework; | ||
| using Moryx.Tests.Workplans.Dummies; | ||
|  | ||
| namespace Moryx.Tests.Workplans | ||
| { | ||
|  | ||
| [TestFixture] | ||
| public class EqualTest | ||
| { | ||
| private Workplan firstWorkplan; | ||
| 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. Maybe better names. What are the differences between each workplan? | ||
| private Workplan secondWorkplan; | ||
| private Workplan thirdWorkplan; | ||
| private Workplan fourthWorkplan; | ||
| private Workplan fifthWorkplan; | ||
| private Workplan sixthWorkplan; | ||
|  | ||
| public Workplan CreateSimpleWorkplan() | ||
| { | ||
| var plan = new Workplan(); | ||
|  | ||
| var start = plan.AddConnector("Start", NodeClassification.Start); | ||
| var end = plan.AddConnector("End", NodeClassification.End); | ||
| var failed = plan.AddConnector("Failed", NodeClassification.Failed); | ||
|  | ||
| var input = start; | ||
| var outputA = plan.AddConnector("A"); | ||
| var outputB = plan.AddConnector("B"); | ||
|  | ||
| plan.AddStep(new AssemblingTask(), new AssemblingParameters(), input, outputA, outputB, failed); | ||
|  | ||
| input = outputA; | ||
| plan.AddStep(new PackagingTask(), new AssemblingParameters(), input, end, end, failed); | ||
|  | ||
| input = outputB; | ||
| plan.AddStep(new ColorizingTask(), new AssemblingParameters(), input, end, failed, failed); | ||
| return plan; | ||
| } | ||
|  | ||
| public Workplan CreateWorkplanWithLoop() | ||
| { | ||
| var plan = new Workplan(); | ||
|  | ||
| var start = plan.AddConnector("Start", NodeClassification.Start); | ||
| var end = plan.AddConnector("End", NodeClassification.End); | ||
| var failed = plan.AddConnector("Failed", NodeClassification.Failed); | ||
|  | ||
| var input = start; | ||
| var outptuA = input; | ||
| var outputB = plan.AddConnector("A"); | ||
|  | ||
| plan.AddStep(new AssemblingTask(), new AssemblingParameters(), input, outptuA, outputB, failed); | ||
|  | ||
| input = outputB; | ||
| plan.AddStep(new PackagingTask(), new AssemblingParameters(), input, outputB, end, failed); | ||
|  | ||
| return plan; | ||
| } | ||
|  | ||
| public Workplan CreateWorkplanWithLoopsAndBranches() | ||
| { | ||
| var plan = new Workplan(); | ||
|  | ||
| var start = plan.AddConnector("Start", NodeClassification.Start); | ||
| var end = plan.AddConnector("End", NodeClassification.End); | ||
| var failed = plan.AddConnector("Failed", NodeClassification.Failed); | ||
|  | ||
| var outputA = plan.AddConnector("A"); | ||
| var outputB = plan.AddConnector("B"); | ||
|  | ||
| plan.AddStep(new AssemblingTask(), new AssemblingParameters(), start, outputA, outputB, failed); | ||
|  | ||
| var input = outputA; | ||
|  | ||
| plan.AddStep(new PackagingTask(), new AssemblingParameters(), input, start, end, failed); | ||
|  | ||
| input = outputB; | ||
|  | ||
| plan.AddStep(new ColorizingTask(), new AssemblingParameters(), input, outputA, end, failed); | ||
|  | ||
| return plan; | ||
| } | ||
|  | ||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| firstWorkplan = CreateSimpleWorkplan(); | ||
| secondWorkplan = CreateSimpleWorkplan(); | ||
|  | ||
| thirdWorkplan = CreateWorkplanWithLoop(); | ||
| fourthWorkplan = CreateWorkplanWithLoop(); | ||
|  | ||
| fifthWorkplan = CreateWorkplanWithLoopsAndBranches(); | ||
| sixthWorkplan = CreateWorkplanWithLoopsAndBranches(); | ||
| } | ||
|  | ||
| [Test] | ||
| public void TestEqualWorkplans() | ||
| { | ||
| bool result = Workplan.Equals(firstWorkplan, secondWorkplan); | ||
| Assert.That(result, Is.True); | ||
| } | ||
|  | ||
| [Test] | ||
| public void TestEqualWorkplansSimpleLoop() | ||
| { | ||
| bool result = Workplan.Equals(thirdWorkplan, fourthWorkplan); | ||
| Assert.That(result, Is.True); | ||
| } | ||
|  | ||
| [Test] | ||
| public void TestEqualWorkplansDoubleLoop() | ||
| { | ||
| bool result = Workplan.Equals(fifthWorkplan, sixthWorkplan); | ||
| Assert.That(result, Is.True); | ||
| } | ||
|  | ||
| [Test] | ||
| public void TestUnequalWorkplans() | ||
| { | ||
| bool r = Workplan.Equals(firstWorkplan, sixthWorkplan); | ||
| Assert.That(r, Is.False); | ||
| } | ||
| } | ||
|  | ||
| } | ||
  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.
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
IWorkplanStepand reflection.