Skip to content

Comments

Priority queue #8

Open
Andrw-404 wants to merge 1 commit intomainfrom
test1
Open

Priority queue #8
Andrw-404 wants to merge 1 commit intomainfrom
test1

Conversation

@Andrw-404
Copy link
Owner

No description provided.

<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">

Choose a reason for hiding this comment

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

StyleCop используйте версии 1.2-beta. 1.1 не знает современного C# и из-за этого генерирует кучу ложных предупреждений

public class Tests
{
[Test]
public void Dequeu_IntegerValue_ShouldReturnCorrectValues()

Choose a reason for hiding this comment

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

Оно "Dequeue" :)


#pragma warning disable SA1600

namespace PriorityQueue.Tests

Choose a reason for hiding this comment

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

Используйте file-scoped namespaces, фигурные скобки тут ни к чему

testQueue.Enqueue(32, 3);
testQueue.Enqueue(55, 2);

Assert.That(testQueue.Dequeue, Is.EqualTo(13));

Choose a reason for hiding this comment

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

Dequeue свойство, что ли? Это архитектурно неправильно, ведь оно меняет состояние объекта при чтении. Это метод должен был быть.

public void Dequeu_EmptyQueue_ShouldThrowAnException()
{
var testQueue = new Queue<bool>();
Assert.Throws<InvalidDataException>(() => testQueue.Dequeue());

Choose a reason for hiding this comment

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

Я бы ожидал InvalidOperationException тут.

Assert.Throws<InvalidDataException>(() => testQueue.Dequeue());
}
}
}

Choose a reason for hiding this comment

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

Нет теста на одинаковые приоритеты

@@ -0,0 +1,7 @@
// <copyright file="Program.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.

Choose a reason for hiding this comment

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

PlaceholderCompany не очень, настроили бы себе шапку с лицензией более содержательно


using PriorityQueue;

Console.WriteLine("Hello world"); No newline at end of file

Choose a reason for hiding this comment

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

Это не нужно, выставили бы OutputType в Library в свойствах проекта

/// Priority queue element.
/// </summary>
/// <typeparam name="T">Type of stored value.</typeparam>
public struct QueueNode<T>

Choose a reason for hiding this comment

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

Он мог бы быть record-ом и писаться в одну строчку :) И вложенным в Queue, внешнему миру про него знать совершенно не нужно

/// The class that implements the queue.
/// </summary>
/// <typeparam name="T">The type of the element value.</typeparam>
public class Queue<T>

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