Skip to content

Conversation

@pavelrubanov
Copy link
Owner

No description provided.

@pavelrubanov pavelrubanov changed the title v1 Bor Mar 15, 2023
@pavelrubanov pavelrubanov changed the title Bor hw2_Bor Mar 15, 2023

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>

Choose a reason for hiding this comment

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

Лучше 7.0, если нет веских оснований использовать LTS-версию (в реальной жизни LTS может быть лучше, потому что позволит отсрочить миграцию на новый .NET, в домашке — никто и так её мигрировать не будет).

using System.Transactions;
using System.Xml.Linq;

namespace Bor

Choose a reason for hiding this comment

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

  • Оно по-английски Trie, а не Bor. Никогда не пишите транслитом.
  • Используйте file-scoped namespaces


namespace Bor
{
public class Bor

Choose a reason for hiding this comment

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

Нужны комментарии ко всем классам и public-методам (свойствам и т.п.)

{
private class BorNode
{
internal Dictionary<char, BorNode> nexts = new ();

Choose a reason for hiding this comment

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

private, объемлющий класс всё равно имеет к этим полям доступ.

private class BorNode
{
internal Dictionary<char, BorNode> nexts = new ();
internal bool isTerminate { get; set; }

Choose a reason for hiding this comment

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

Свойства всегда именуются с заглавной. И интересно, почему nexts не свойство, а остальные — свойства

{
public class Program
{
public static void Main()

Choose a reason for hiding this comment

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

Это вообще не надо, собирайте бор как библиотеку

Assert.IsTrue(bor.Add("NewString"));
Assert.IsTrue(bor.Add("NewStr"));
Assert.That(bor.Size, Is.EqualTo(2));
}

Choose a reason for hiding this comment

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

Надо пустые строки между методами

[Test]
public void AddUncontainedStringShouldAddAndReturnTrue()
{
Bor bor = new Bor();

Choose a reason for hiding this comment

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

Suggested change
Bor bor = new Bor();
var bor = new Bor();

[Test]
public void AddEmptyString()
{
var bor = new Bor();

Choose a reason for hiding this comment

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

Создание бора можно вынести в метод с атрибутом SetUp, если объявить бор как поле тестового класса

public void AddNullStringShouldThrowException()
{
Bor bor = new();
Assert.Catch<ArgumentNullException>(() => bor.Add(null));

Choose a reason for hiding this comment

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

Suggested change
Assert.Catch<ArgumentNullException>(() => bor.Add(null));
Assert.Throws<ArgumentNullException>(() => bor.Add(null));

Мы же знаем, какое именно исключение должно быть брошено

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.

3 participants