public async Task <ulong> CreateOrUpdateStepArtifactOption(StepArtifactOption option) { using (var db = await DbConnectionFactory.OpenAsync()) { return(await db.CreateOrUpdateStepArtifactOption(option)); } }
public async Task It_Should_Delete_Step_Artifact_Option() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .Returns(new Step()); stepRepository.GetStepArtifact(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(new StepArtifact()); var existingStepArtifactOption = new StepArtifactOption { Id = 123 }; stepRepository.GetStepArtifactOption(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(existingStepArtifactOption); stepRepository.DeleteStepArtifactOption(Arg.Any <ulong>()).Returns(true); var request = new DeleteStepArtifactOptionRequest(); // Act var response = await Sut.Delete(request); // Assert response.Should().NotBeNull(); await stepRepository.Received().DeleteStepArtifactOption(Arg.Is <ulong>(a => a == existingStepArtifactOption.Id)); }
public async Task It_Should_Update_StepArtifact_Option() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Get(Arg.Any <string>(), Arg.Any <string>()) .Returns(new Step()); stepRepository.GetStepArtifact(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(new StepArtifact { Id = 123 }); var stepArtifactOption = new StepArtifactOption { Id = 456 }; stepRepository.GetStepArtifactOption(Arg.Any <ulong>(), Arg.Any <string>()) .Returns(stepArtifactOption); var request = UpdateStepArtifactOptions.Compress; request.StepName = TestStepName; request.ArtifactName = TestStepArtifactName; // Act var response = await Sut.Put(request); // Assert response.Should().NotBeNull(); await stepRepository.Received().CreateOrUpdateStepArtifactOption(Arg.Is <StepArtifactOption>(a => a.Id == 456 && a.StepArtifactId == 123 && a.Name == request.OptionName && a.Description == request.Description)); }
internal static async Task <ulong> CreateOrUpdateStepArtifactOption(this IDbConnection db, StepArtifactOption option) { await db.SaveAsync(option, true); return(option.Id); }