public async Task It_Should_Delete_Batch_Variable() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); var existingBatchVariable = new BatchVariable { Id = 123 }; batchRepository.GetBatchVariable(Arg.Any <string>(), Arg.Any <string>()) .Returns(existingBatchVariable); batchRepository.DeleteBatchVariable(Arg.Any <ulong>()).Returns(true); var request = new DeleteBatchVariableRequest(); // Act var response = await Sut.Delete(request); // Assert response.Should().NotBeNull(); await batchRepository.Received().DeleteBatchVariable(Arg.Is <ulong>(a => a == existingBatchVariable.Id)); }
public async Task It_Should_Update_BatchVariable() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); var batchVariable = new BatchVariable { Id = 123 }; batchRepository.GetBatchVariable(Arg.Any <string>(), Arg.Any <string>()) .Returns(batchVariable); var request = UpdateBatchVariables.Environment; request.BatchId = TestBatchId; // Act var response = await Sut.Put(request); // Assert response.Should().NotBeNull(); await batchRepository.Received().CreateOrUpdateBatchVariable(Arg.Is <BatchVariable>(a => a.Id == 123 && a.BatchId == TestBatchId && a.Description == request.Description)); }
public async Task <ulong> CreateOrUpdateBatchVariable(BatchVariable variable) { using (var db = await DbConnectionFactory.OpenAsync()) { await db.CreateOrUpdateBatchVariable(variable); return(variable.Id); } }
internal static async Task <bool> CreateOrUpdateBatchVariable(this IDbConnection db, BatchVariable variable) { return(await db.SaveAsync(variable, true)); }