поправлены дубли шагов
This commit is contained in:
+64
@@ -150,6 +150,70 @@ public sealed class TemplateRouteStepServiceTests : IClassFixture<PostgresDataba
|
||||
directorTansu.IsSuccess.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Два шага с одним типом руководителя, но разными условиями появления — допустимы")]
|
||||
public async Task CreateAsync_SameHeadTypeDifferentConditions_BothSucceed()
|
||||
{
|
||||
// Arrange — условия появления взаимоисключающи по данным заявки, поэтому
|
||||
// в конкретный резолв попадёт только один из двух шагов.
|
||||
var routeId = await CreateRouteAsync("Route with head type per condition", byProject: false, listName: "Requests");
|
||||
|
||||
// Action
|
||||
var small = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(1, null, null, null, HeadType.Chief, RouteStepStatus.Approval, false, "Amount", ComparisonOperator.LessThan, "1000"),
|
||||
CancellationToken.None);
|
||||
var big = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(2, null, null, null, HeadType.Chief, RouteStepStatus.Approval, false, "Amount", ComparisonOperator.GreaterThan, "1000"),
|
||||
CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
small.IsSuccess.ShouldBeTrue();
|
||||
big.IsSuccess.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Два шага с одним конкретным исполнителем, но разными условиями появления — допустимы")]
|
||||
public async Task CreateAsync_SameExecutorDifferentConditions_BothSucceed()
|
||||
{
|
||||
// Arrange
|
||||
var routeId = await CreateRouteAsync("Route with executor per condition", byProject: false, listName: "Requests");
|
||||
|
||||
// Action
|
||||
var small = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(1, "a@b.kz", null, null, null, RouteStepStatus.Approval, false, "Amount", ComparisonOperator.LessThan, "1000"),
|
||||
CancellationToken.None);
|
||||
var big = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(2, "a@b.kz", null, null, null, RouteStepStatus.Approval, false, "Amount", ComparisonOperator.GreaterThan, "1000"),
|
||||
CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
small.IsSuccess.ShouldBeTrue();
|
||||
big.IsSuccess.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Два шага с одним типом руководителя и одинаковым условием появления — конфликт")]
|
||||
public async Task CreateAsync_SameHeadTypeSameCondition_ReturnsFailedResult()
|
||||
{
|
||||
// Arrange
|
||||
var routeId = await CreateRouteAsync("Route with head type same condition", byProject: false, listName: "Requests");
|
||||
var first = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(1, null, null, null, HeadType.Chief, RouteStepStatus.Approval, false, "Amount", ComparisonOperator.GreaterThan, "1000"),
|
||||
CancellationToken.None);
|
||||
first.IsSuccess.ShouldBeTrue();
|
||||
|
||||
// Action — то же условие, другой статус
|
||||
var second = await _service.CreateAsync(
|
||||
routeId,
|
||||
new CreateTemplateRouteStepRequest(2, null, null, null, HeadType.Chief, RouteStepStatus.Execution, false, "Amount", ComparisonOperator.GreaterThan, "1000"),
|
||||
CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
second.IsFailed.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Обновление шага, при котором HeadType не меняется, не конфликтует само с собой")]
|
||||
public async Task UpdateAsync_SameHeadTypeOnSameStep_DoesNotConflictWithItself()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user