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

NameFilterTests refactor #11

Merged

Conversation

monerofglory
Copy link
Contributor

@monerofglory monerofglory commented Nov 26, 2023

What is changing?

  • Moved to system under test (sut) nomenclature.
  • Moved to single-purpose testing methods.
  • Moved sut to constructor to save calls.
  • Added expansion through DataRow usage.
  • Removed calls to Obselete methods.

Why does the change need to happen?

  • It addresses a bug
  • [X ] It makes the library easier or more appealing to use
  • [X ] It makes the library easier to maintain
  • [X ] It future-proofs the library

Other ways to improve:

Issue 1

  • I noticed during testing that stacking _sut.UsingFilter(x => x.DoNotAllow(character)); does not work.
    E.g:
_sut.UsingFilter(x => x.DoNotAllow("a"));
_sut.UsingFilter(x => x.DoNotAllow("e"));

Does not seem to capture it

Issue 2

Look into the AAA structure for setting up unit tests. It stands for Arrange, Act, Assert and can be used to make your testing much easier to read and structure.

E.g:

// Arrange
sut.UsingFilter(x => x.DoNotAllow("a"));

// Act
var result = sut.Next()

// Assert
Assert.NotNull(result)

As always, feel free to reach out if you want me to go through any of these. Thanks for reviewing!

…e testing methods. Moved sut to constructor to save calls. Added expansion through DataRow usage. Removed calls to Obselete methods.
@kesac kesac self-assigned this Nov 28, 2023
@kesac
Copy link
Owner

kesac commented Nov 28, 2023

Thanks for taking the initiative in getting the project to adopt best test practices!

Looks good to me and I will read up on the AAA structure as you recommend.

For issue 1, the call to UsingFilter() sets and also replaces the filter of the generator.

So this setup:

generator.UsingFilter(x => x.DoNotAllow("a"));
generator.UsingFilter(x => x.DoNotAllow("e"));

would be better expressed as:

generator.UsingFilter(x => x
    .DoNotAllow("a")
    .DoNotAllow("e"));

I will make sure this clearer in the XML documention

Copy link
Owner

@kesac kesac left a comment

Choose a reason for hiding this comment

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

Looks good to me

@kesac kesac merged commit 6a35303 into kesac:main Nov 28, 2023
1 check passed
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