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

Null objects task #16

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Null objects task #16

merged 1 commit into from
Oct 10, 2024

Conversation

kamendov-maxim
Copy link
Owner

No description provided.

/// Interface for null checker used in NullCounter
/// </summary>
/// <typeparam name="T">Type of which will be elements you check for null</typeparam>
public interface INullChecker<T>

Choose a reason for hiding this comment

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

Suggested change
public interface INullChecker<T>
public interface INullChecker<in T>

@@ -0,0 +1,15 @@
namespace Zachet;

Choose a reason for hiding this comment

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

Пространство имён должно совпадать с именем проекта

Comment on lines +13 to +16
public bool IsNull(int value)
{
return value == 0;
}

Choose a reason for hiding this comment

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

Suggested change
public bool IsNull(int value)
{
return value == 0;
}
public bool IsNull(int value)
=> value == 0;

/// <param name="list">Collection implementing IEnumerable (to iterate through it)</param>
/// <param name="nullChecker">Object which can check if element of T type is null</param>
/// <returns>Count of null objects</returns>
public static int CountNullObjects<T>(IEnumerable<T> list, INullChecker<T> nullChecker)

Choose a reason for hiding this comment

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

Без вариантности тут слишком жёсткое ограничение на типы

<Nullable>enable</Nullable>
</PropertyGroup>

</Project>

Choose a reason for hiding this comment

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

StyleCop?

public void ListWithNullsTest()
{
Assert.That(NullCounter.CountNullObjects<int>(listWithNulls, intNullChecker), Is.EqualTo(3));
}

Choose a reason for hiding this comment

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

TestCaseData?

@kamendov-maxim kamendov-maxim merged commit 3c6a758 into master Oct 10, 2024
6 checks 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