Skip to content
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

Hw2/team2 #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Hw2/team2 #11

wants to merge 3 commits into from

Conversation

natalyturbina
Copy link

ДЗ команды 2

Comment on lines +29 to +44
var saved = false;
try
{
await _orderRepository.SaveAsync(new ProposalData
{
CompanyEmail = dto.CompanyEmail,
CompanyName = dto.CompanyName,
CompanyNumber = dto.CompanyNumber,
EmployeesAmount = dto.EmployeesAmount
});

saved = true;
}
catch (Exception e)
{
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Вы тут немного перемудрили с try-catch и saved. Лучше отказы инфраструктуры в бизнес-логику не встраивать (как это у вас в CreateNotification сделано), а делать их "вокруг" бизнес-процесса. Т.е. в идеальной ситуации весь этот хэндлер будет обернут в трай-кетч с какой-нибудь ретрай-политикой и его инфраструктурные операторы будут идемпотентными.

При этом в самом коде будет чистое-бизнесовое:

  • Если валидно - сохраняем заявку
  • Если подходят условия для отправки - отправляем письмо

}

[TestMethod]
public void ShouldReturnEmailDto_WhenCorrectData()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Не совсем бизнесовый нейминг: бизнес не знает, что такое дто. Бизнес не знает, что значит Return.
Представьте, что вы название теста транслируете вашему ПМ-у или какому-нибудь менеджеру из m1/m2. Поймут ли они перевод?

А вот если будет, например,
ShouldCreateNotification_When.. - как будто уже и понятнее
или
ShouldNotCreateNotification
ShouldFail
ShouldCreateNothing

в общем, приветствуются термины бизнеса, а не термины из языка программирования (Return/False/True/Null/etc)

Comment on lines +47 to +49
var emailDto = NotificationService.CreateNotification(notificationRequest);

emailDto.Should().NotBeNull();
Copy link
Collaborator

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.

5 participants