Skip to content

Add test1 task - #4

Open
kamenkremen wants to merge 4 commits into
mainfrom
Test1
Open

Add test1 task#4
kamenkremen wants to merge 4 commits into
mainfrom
Test1

Conversation

@kamenkremen

Copy link
Copy Markdown
Owner

No description provided.

@yurii-litvinov yurii-litvinov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Так оно не работает потому, что основной проект в папке MD5, а тесты — в его подпапке, MD5/Tests. Поэтому .NET думает, что тесты — это просто часть исходников основного проекта. Надо было по разным подпапкам разложить. Ужас, забыли как проекты на .NET создавать :)

А ещё Вы, видимо, в панике выложили бинари и прочие результаты сборки.

В целом всё так, но из-за крайней нетехнологичности потеряли много баллов.

Comment thread MD5/MD5Async.cs
/// <summary>
/// Class that computes check sum of the directory in multiple threads.
/// </summary>
public static class MD5Async

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Есть асинхронный код и есть параллельный код, и это разные вещи (причём ортогональные, одно другому не мешает). Тут, наверное, имелось в виду MD5Parallel.

Comment thread MD5/MD5Async.cs
/// <returns>Task, that computes the check sum for directory or file.</returns>
public static async Task<byte[]> ComputeSum(string path)
{
if (Path.HasExtension(path))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Линуксоиды слегка напуганы таким способом отличать файл от директории

Comment thread MD5/MD5Async.cs
Comment on lines +16 to +24
public static async Task<byte[]> ComputeSum(string path)
{
if (Path.HasExtension(path))
{
return await MD5Async.ComputeFile(path);
}

return await MD5Async.ComputeDirectory(path);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
public static async Task<byte[]> ComputeSum(string path)
{
if (Path.HasExtension(path))
{
return await MD5Async.ComputeFile(path);
}
return await MD5Async.ComputeDirectory(path);
}
public static async Task<byte[]> ComputeSum(string path)
=> Path.HasExtension(path) ?
await MD5Async.ComputeFile(path)
: await MD5Async.ComputeDirectory(path);

Comment thread MD5/MD5Async.cs
private static async Task<byte[]> ComputeDirectory(string path)
{
var files = Directory.GetFiles(path);
var direcoties = Directory.GetDirectories(path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Опечатка

Comment thread MD5/MD5Sequential.cs
{
var hash = MD5.Create();
return hash.ComputeHash(File.OpenRead(path));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот, например, это тоже вполне могло бы быть асинхронно. Но не параллельно, просто последовательно вызывались бы асинхронные методы

Comment thread MD5/Program.cs
Comment on lines +22 to +27
Console.WriteLine(
"Check sum = (parallel calculations){0} = (sequential calculations){1}, time for sequential MD5 = {2}, time for parallel MD5 = {3}.",
Encoding.UTF8.GetString(parallelResult),
Encoding.UTF8.GetString(sequentialResult),
sequentialTime,
parallelTime);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут явно не хватает отступов при переносе строки, и ещё можно было бы интерполированные строки использовать, не зря же их в язык завезли давно.

Comment thread MD5/Tests/Test.cs
Comment on lines +9 to +12
public void TestOneDirectory()
{
Assert.That(Encoding.UTF8.GetString(MD5Sequential.ComputeSum("../testFolder/test1")), Is.EqualTo(Encoding.UTF8.GetString(MD5Async.ComputeSum("../testFolder/test1").Result)));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Однострочники лучше через => писать

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