Skip to content

Lambda functions#7

Open
KirillBorisovich wants to merge 9 commits intomainfrom
LambdaFunctions
Open

Lambda functions#7
KirillBorisovich wants to merge 9 commits intomainfrom
LambdaFunctions

Conversation

@KirillBorisovich
Copy link
Owner

No description provided.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>

Choose a reason for hiding this comment

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

Можно здесь указывать тип Library, чтобы не оставлять такой бесполезный Program :)

/// <summary>
/// Transformations over list.
/// </summary>
public class Transformations

Choose a reason for hiding this comment

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

Класс тоже стоит пометить static

[Test]
public void MapTest()
{
List<int> sample = new() { 2, 4, 6 };

Choose a reason for hiding this comment

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

Зачем это?

Comment on lines +15 to +22
if (item % 2 != 0)
{
result = false;
break;
}
}

Assert.That(result, Is.True);

Choose a reason for hiding this comment

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

Suggested change
if (item % 2 != 0)
{
result = false;
break;
}
}
Assert.That(result, Is.True);
if (item % 2 != 0)
{
Assert.Fail()
}
}
Assert.Pass();

Comment on lines +30 to +35
if (resultList.Count == 1 && resultList[0] == 2)
{
result = true;
}

Assert.That(result, Is.True);

Choose a reason for hiding this comment

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

Assert.That(resultList, Has.Exactly(1).Items);
Assert.That(resultList[0], Is.EqualTo(2));

Лучше не объединять проверки, чтобы можно было понять, где именно тест упал

/// <returns>Transformed list.</returns>
public static List<int> Map(List<int> list, Func<int, int> function)
{
List<int> result = new(list);

Choose a reason for hiding this comment

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

Suggested change
List<int> result = new(list);
List<int> result = new(list.Count);

Чтобы просто так список не копировать

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