Skip to content
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
29 changes: 25 additions & 4 deletions SysML2.NET.Tests/Extend/ActionDefinitionExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,39 @@
namespace SysML2.NET.Tests.Extend
{
using System;

using NUnit.Framework;


using SysML2.NET.Core.POCO.Core.Types;
using SysML2.NET.Core.POCO.Systems.Actions;
using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage;
using SysML2.NET.Extensions;

[TestFixture]
public class ActionDefinitionExtensionsTestFixture
{
[Test]
public void ComputeAction_ThrowsNotSupportedException()
public void VerifyComputeAction()
{
Assert.That(() => ((IActionDefinition)null).ComputeAction(), Throws.TypeOf<NotSupportedException>());
Assert.That(() => ((IActionDefinition)null).ComputeAction(), Throws.TypeOf<ArgumentNullException>());

var emptyActionDefinition = new ActionDefinition();

Assert.That(emptyActionDefinition.ComputeAction(), Has.Count.EqualTo(0));

// Only ActionUsage instances must be returned; a bare Usage must be filtered out.
var subject = new ActionDefinition();
var actionUsage = new ActionUsage();
var bareUsage = new Usage();

subject.AssignOwnership(new FeatureMembership(), actionUsage);
subject.AssignOwnership(new FeatureMembership(), bareUsage);

using (Assert.EnterMultipleScope())
{
Assert.That(subject.ComputeAction(), Does.Contain(actionUsage));
Assert.That(subject.ComputeAction(), Does.Not.Contain(bareUsage));
}
}
}
}
6 changes: 4 additions & 2 deletions SysML2.NET/Extend/ActionDefinitionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace SysML2.NET.Core.POCO.Systems.Actions
{
using System;
using System.Collections.Generic;
using System.Linq;

using SysML2.NET.Core.Core.Types;
using SysML2.NET.Core.Root.Namespaces;
Expand Down Expand Up @@ -75,10 +76,11 @@ internal static class ActionDefinitionExtensions
/// <returns>
/// the computed result
/// </returns>
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
internal static List<IActionUsage> ComputeAction(this IActionDefinition actionDefinitionSubject)
{
throw new NotSupportedException("Create a GitHub issue when this method is required");
return actionDefinitionSubject == null
? throw new ArgumentNullException(nameof(actionDefinitionSubject))
: [.. actionDefinitionSubject.usage.OfType<IActionUsage>()];
}

}
Expand Down
Loading