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

ADSECGH-92 coverage for AdSecProfiles.cs #123

Merged
merged 4 commits into from
Feb 18, 2025

Conversation

DominikaLos
Copy link
Collaborator

No description provided.

@DominikaLos DominikaLos changed the title refactor: increasing coverage for AdSecProfiles.cs ADSECGH-92 coverage for AdSecProfiles.cs Feb 17, 2025
@DominikaLos DominikaLos requested a review from psarras February 18, 2025 08:19
Copy link
Collaborator

@psarras psarras left a comment

Choose a reason for hiding this comment

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

simplify asserts

    private IProfile[] profiles = {
      GetAPerimeterProfile(),
      GetARectangleProfile()
    };

    [Fact]
    public void CheckProfiles_NotNull() {
      foreach (var profile in profiles) {
        var result = AdSecProfiles.CreateProfile(profile);
        Assert.NotNull(result);
      }
    }
    [Fact]
    public void CheckProfiles_HaveTheRightType() {
      foreach (var profile in profiles) {
        var result = AdSecProfiles.CreateProfile(profile);
        Assert.Equal($"I{profile.GetType().Name}_Implementation", result.GetType().Name);
      }
    }

    private static void NotNullAndRightType(Oasys.Profiles.IProfile result, IProfile profile) {
      Assert.NotNull(result);
      Assert.Equal($"I{profile.GetType().Name}_Implementation", result.GetType().Name);
    }


Simplify Gets

    private static SheetPileProfile GetASheetPileProfile() {
      var rotationInDegrees = new Angle(0, DefaultUnits.AngleUnit);

      var lengthOne = LengthOne();
      return new SheetPileProfile() {
        Rotation = rotationInDegrees,
        BottomFlangeWidth = lengthOne,
        FlangeThickness = lengthOne,
        Depth = lengthOne,
        TopFlangeWidth = lengthOne,
        WebThickness = lengthOne,
        Width = lengthOne,
      };
    }

    private static Length LengthOne() {
      return new Length(1, DefaultUnits.LengthUnitGeometry);
    }
~
  • Rename the Method to "GetA"
  • Adjust the Units to use the default Units
  • Extract the Unit of One in a resulable method
  • Reuse this one for all values, do not differentiate unless it crashes
  • Move the class that has the "GetA" methods to another file, which we will be referencing on our tests whenever we need a profile.

@psarras psarras merged commit e1b70ad into main Feb 18, 2025
7 checks passed
@psarras psarras deleted the task/ADSEC-92-Coverage-for-AdsecProfiles branch February 18, 2025 14:09
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.5%. Comparing base (3eac3c7) to head (0343ecd).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #123     +/-   ##
=======================================
+ Coverage   43.7%   44.5%   +0.8%     
=======================================
  Files         95      95             
  Lines       6656    6667     +11     
  Branches     867     869      +2     
=======================================
+ Hits        2912    2973     +61     
+ Misses      3665    3618     -47     
+ Partials      79      76      -3     
Files with missing lines Coverage Δ
AdSecGH/Helpers/AdSecProfiles.cs 100.0% <100.0%> (+80.6%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants