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

Initial implementations #26

Merged
merged 23 commits into from
Aug 26, 2024
Merged

Initial implementations #26

merged 23 commits into from
Aug 26, 2024

Conversation

jackschonherr
Copy link
Collaborator

No description provided.

Console.WriteLine();
hasHeaderWritten = true;
}
CheckIfSameHeaders(res);

Choose a reason for hiding this comment

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

This is a very good addition for safety, but not a very good addition for speed. Since this is really a tool to support unit tests, I think this is great.

for (int i = 0; i < res.GetResultItems().Length; i++)
{
Console.Write(res.GetResultItems()[i].ResultName);
if (i < res.GetResultItems().Length - 1)

Choose a reason for hiding this comment

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

an alternative pattern is to write the first row, loop for i=1 to < length. for each i'th option write , value. that can eliminate the if check on each element.

@@ -8,6 +8,11 @@ public Result(ResultItem[] resultItems)
_resultItems = resultItems;
}

public ResultItem[] GetResultItems()

Choose a reason for hiding this comment

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

a nice thing about unit tests is that you implement an activity that seeks to reach a goal (like writing results) and you find that your interfaces or implementations are missing things. That helps you ensure your code does what it needs to do. Great find and fix.

[Fact]
public void TestHeaders()
{
var stringWriter = new StringWriter();

Choose a reason for hiding this comment

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

great addition in a unit test to verify behavior with an assert.

Another way you could do this is to write a "stringbuilderresultswriter" where the result is internally stored in a string builder. I like your approach because it can be utilized in many ways.

public class StructureTest
{
[Fact]
public void TestSimpleDepth()

Choose a reason for hiding this comment

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

this is a great first test. write a test to write to the results writer too

@Brennan1994
Copy link
Contributor

Brennan1994 commented Aug 22, 2024

Testing console output is painful and poorly supported. I suggested to Jack, for the ConsoleWriter, to move the business logic of creating the string into a separate method, and honor the Write(Result res) interface with a very simple implementatin that calls the business logic, then writes the output string to console.

I think that cleans up the testing and still accomplishes the goal.

@Brennan1994
Copy link
Contributor

Brennan1994 commented Aug 22, 2024

Looks like using the Issue number only soft links the commit to the issue, but doesn't close it out once merged. Moving forward, lets use Fix #xx as the syntax for commits that address specific issues. When we miss them, which is no big deal, add them manually from the PR page under "Development"

I've added some of them already.

Copy link

@HenryGeorgist HenryGeorgist left a comment

Choose a reason for hiding this comment

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

looks great

@@ -7,15 +7,18 @@
namespace USACE.HEC.Geography;
public class BoundingBox
{
private Location _upperLeft;
private Location _lowerRight;
public Location _upperLeft;

Choose a reason for hiding this comment

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

this looks "sus"

@@ -1,8 +1,8 @@
namespace USACE.HEC.Geography;
public class BoundingBox
{
public Location _upperLeft;
public Location _lowerRight;
private Location _upperLeft;

Choose a reason for hiding this comment

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

yay!

ConsequencesTest/DepthHazardTest.cs Show resolved Hide resolved
ConsequencesTest/DepthHazardTest.cs Outdated Show resolved Hide resolved
@jackschonherr jackschonherr merged commit 92b1a1b into main Aug 26, 2024
1 check passed
@jackschonherr jackschonherr deleted the initial-implementations branch August 26, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment