-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
/// 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public interface INullChecker<T> | |
public interface INullChecker<in T> |
@@ -0,0 +1,15 @@ | |||
namespace Zachet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пространство имён должно совпадать с именем проекта
public bool IsNull(int value) | ||
{ | ||
return value == 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestCaseData?
No description provided.