public async Task It_Should_Create_Step() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.DoesStepExist(Arg.Any <string>(), Arg.Any <string>()) .Returns(false); var request = CreateSteps.Build; request.BatchId = TestBatchId; // Act var response = await Sut.Post(request); // Assert response.Should().NotBeNull(); await stepRepository.Received().Create(Arg.Is <Step>(a => a.BatchId == request.BatchId && a.Name == request.StepName && a.Description == request.Description && a.Options.Count == request.Options.Count && a.Variables.Count == request.Variables.Count && a.Commands.Count == request.Commands.Count && a.Artifacts.Count == request.Artifacts.Count)); }
public async Task <CreateStepResponse> Post(CreateStepRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } if (await stepRepository.DoesStepExist(request.BatchId, request.StepName)) { throw Err.StepAlreadyExists(request.StepName); } var step = request.ConvertTo <Step>(); await stepRepository.Create(step); return(new CreateStepResponse()); }