Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public async Task <ulong> CreateOrUpdateBatchVariable(BatchVariable variable)
        {
            using (var db = await DbConnectionFactory.OpenAsync())
            {
                await db.CreateOrUpdateBatchVariable(variable);

                return(variable.Id);
            }
        }
Пример #4
0
 internal static async Task <bool> CreateOrUpdateBatchVariable(this IDbConnection db, BatchVariable variable)
 {
     return(await db.SaveAsync(variable, true));
 }