-
Notifications
You must be signed in to change notification settings - Fork 0
hw2_Bor #2
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
base: main
Are you sure you want to change the base?
hw2_Bor #2
Conversation
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net6.0</TargetFramework> |
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.
Лучше 7.0, если нет веских оснований использовать LTS-версию (в реальной жизни LTS может быть лучше, потому что позволит отсрочить миграцию на новый .NET, в домашке — никто и так её мигрировать не будет).
| using System.Transactions; | ||
| using System.Xml.Linq; | ||
|
|
||
| namespace Bor |
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.
- Оно по-английски Trie, а не Bor. Никогда не пишите транслитом.
- Используйте file-scoped namespaces
|
|
||
| namespace Bor | ||
| { | ||
| public class Bor |
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-методам (свойствам и т.п.)
| { | ||
| private class BorNode | ||
| { | ||
| internal Dictionary<char, BorNode> nexts = new (); |
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.
private, объемлющий класс всё равно имеет к этим полям доступ.
| private class BorNode | ||
| { | ||
| internal Dictionary<char, BorNode> nexts = new (); | ||
| internal bool isTerminate { get; set; } |
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.
Свойства всегда именуются с заглавной. И интересно, почему nexts не свойство, а остальные — свойства
| { | ||
| public class Program | ||
| { | ||
| public static void Main() |
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.
Это вообще не надо, собирайте бор как библиотеку
| Assert.IsTrue(bor.Add("NewString")); | ||
| Assert.IsTrue(bor.Add("NewStr")); | ||
| Assert.That(bor.Size, Is.EqualTo(2)); | ||
| } |
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.
Надо пустые строки между методами
| [Test] | ||
| public void AddUncontainedStringShouldAddAndReturnTrue() | ||
| { | ||
| Bor bor = new Bor(); |
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.
| Bor bor = new Bor(); | |
| var bor = new Bor(); |
| [Test] | ||
| public void AddEmptyString() | ||
| { | ||
| var bor = new Bor(); |
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.
Создание бора можно вынести в метод с атрибутом SetUp, если объявить бор как поле тестового класса
| public void AddNullStringShouldThrowException() | ||
| { | ||
| Bor bor = new(); | ||
| Assert.Catch<ArgumentNullException>(() => bor.Add(null)); |
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.
| Assert.Catch<ArgumentNullException>(() => bor.Add(null)); | |
| Assert.Throws<ArgumentNullException>(() => bor.Add(null)); |
Мы же знаем, какое именно исключение должно быть брошено
No description provided.