Exemplo n.º 1
0
        public async Task It_Should_Delete_Step_Option()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);

            stepRepository.Get(Arg.Any <string>(), Arg.Any <string>())
            .Returns(new Step());

            var existingStepOption = new StepOption
            {
                Id = 123
            };

            stepRepository.GetStepOption(Arg.Any <ulong>(), Arg.Any <string>())
            .Returns(existingStepOption);

            var request = new DeleteStepOptionRequest();

            // Act
            var response = await Sut.Delete(request);

            // Assert
            response.Should().NotBeNull();
            await stepRepository.Received().DeleteStepOption(Arg.Is <ulong>(a =>
                                                                            a == existingStepOption.Id));
        }
Exemplo n.º 2
0
 public async Task <ulong> CreateOrUpdateStepOption(StepOption option)
 {
     using (var db = await DbConnectionFactory.OpenAsync())
     {
         return(await db.CreateOrUpdateStepOption(option));
     }
 }
Exemplo n.º 3
0
        public void InitSP(int[] steps, bool has_steady_state)
        {
            StressPeriods.Clear();
            if (has_steady_state)
            {
                StressPeriod sp = new StressPeriod()
                {
                    ID         = 1,
                    Length     = 1,
                    Multiplier = 1,
                    State      = ModelState.SS
                };
                sp.Dates.Add(this.Start);
                var op = new StepOption(sp.ID, 1);
                sp.StepOptions.Add(op);
                AddSP(sp);
            }

            int start_index = 0;

            for (int i = 0; i < steps.Length; i++)
            {
                StressPeriod sp = new StressPeriod()
                {
                    Length     = steps[i],
                    Multiplier = 1,
                    State      = ModelState.TR
                };
                if (has_steady_state)
                {
                    sp.ID = i + 2;
                }
                else
                {
                    sp.ID = i + 1;
                }
                sp.Dates = Timeline.GetRange(start_index, steps[i]);
                for (int n = 0; n < steps[i]; n++)
                {
                    var op = new StepOption(sp.ID, n + 1);
                    sp.StepOptions.Add(op);
                }
                AddSP(sp);
                start_index += steps[i];
            }
        }
Exemplo n.º 4
0
 public StepOptionBuilder()
 {
     Configuration = new StepOption();
 }
Exemplo n.º 5
0
 public StepOptionBuilder()
 {
     Configuration = StepOption.Default;
 }
Exemplo n.º 6
0
        public void AddMessageHandler <TMessage, TMessageContext>(Guid globalMessageId, Func <TMessage, TMessageContext, Task> func, StepOption configuration) where TMessageContext : IMessageContext
        {
            var sequence = _sequenceRepository.GetOrCreate(globalMessageId);

            sequence.StepDefinitions.Add(new StepDefinition
            {
                Handler         = (o, context) => func((TMessage)o, (TMessageContext)context),
                Type            = typeof(TMessage),
                Optional        = configuration?.Optional ?? false,
                AbortsExecution = configuration?.AbortsExecution ?? false
            });
            _sequenceRepository.Update(sequence);
        }
Exemplo n.º 7
0
        internal static async Task <ulong> CreateOrUpdateStepOption(this IDbConnection db, StepOption option)
        {
            await db.SaveAsync(option, true);

            return(option.Id);
        }