/// <summary> /// Determines whether the actual number is close to an expected value within a given within. /// </summary> /// <param name="check">The fluent check to be extended.</param> /// <param name="expected">The expected value.</param> /// <param name="within">The within.</param> /// <returns>A continuation check.</returns> public static ICheckLink <ICheck <decimal> > IsCloseTo(this ICheck <decimal> check, decimal expected, decimal within) { var range = new RangeBlock(expected, within); ExtensibilityHelper.BeginCheck(check) .FailWhen(sut => !range.IsInRange(sut), "The {0} is outside the expected value range.") .DefineExpectedValue(range).OnNegate("The {0} is within the expected range, whereas it must not.") .EndCheck(); return(ExtensibilityHelper.BuildCheckLink(check)); }
/// <summary> /// Determines whether the actual number is close to an expected value within a given within. /// </summary> /// <param name="check">The fluent check to be extended.</param> /// <param name="expected">The expected value.</param> /// <param name="within">The within.</param> /// <returns>A continuation check.</returns> public static ICheckLink <ICheck <float> > IsCloseTo(this ICheck <float> check, Double expected, Double within) { var range = new RangeBlock(expected, within); ExtensibilityHelper.BeginCheck(check). FailsIf((sut) => !range.IsInRange(sut), "The {0} is outside the expected value range."). Expecting(range). Negates("The {0} is within the expected range, whereas it must not."). EndCheck(); return(ExtensibilityHelper.BuildCheckLink(check)); }
private void StructuresOnAddingNew(object sender, AddingNewEventArgs e) { var ss = _structures.LastOrDefault(); if (ss == null) { ss = new RangeBlock(BlockType.桥梁, 0, 0); } else { ss = (RangeBlock)ss.Clone(); ss.StartStation = ss.EndStation; } e.NewObject = ss; }
public async Task If_AsDateRange_PreviousBlock_ThenLastBlockContainsDates() { // ARRANGE // Create previous blocks using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { var rangeBlocks = await executionContext.GetDateRangeBlocksAsync(x => x.WithRange(new DateTime(2016, 1, 1), new DateTime(2016, 1, 31, 23, 59, 59, 999).AddMilliseconds(-1), new TimeSpan(1, 0, 0, 0)) .OverrideConfiguration() .MaximumBlocksToGenerate(50)); foreach (var rangeBlock in rangeBlocks) { await rangeBlock.StartAsync(); await rangeBlock.CompleteAsync(); } } } IDateRangeBlock expectedLastBlock = new RangeBlock("0", 1, new DateTime(2016, 1, 31).Ticks, new DateTime(2016, 1, 31, 23, 59, 59, 997).Ticks, BlockType.DateRange); // ACT IDateRangeBlock lastBlock = null; using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { lastBlock = await executionContext.GetLastDateRangeBlockAsync(LastBlockOrder.LastCreated); } } // ASSERT Assert.Equal(expectedLastBlock.StartDate, lastBlock.StartDate); Assert.Equal(expectedLastBlock.EndDate, lastBlock.EndDate); }
public async Task If_AsNumericRange_PreviousBlock_ThenLastBlockContainsDates() { // ARRANGE // Create previous blocks using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { var rangeBlocks = await executionContext.GetNumericRangeBlocksAsync(x => x.WithRange(1, 1000, 100)); foreach (var rangeBlock in rangeBlocks) { await rangeBlock.StartAsync(); await rangeBlock.CompleteAsync(); } } } var expectedLastBlock = new RangeBlock("0", 1, 901, 1000, BlockType.NumericRange); // ACT INumericRangeBlock lastBlock = null; using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { lastBlock = await executionContext.GetLastNumericRangeBlockAsync(LastBlockOrder.MaxRangeStartValue); } } // ASSERT Assert.Equal(expectedLastBlock.RangeBeginAsInt(), lastBlock.StartNumber); Assert.Equal(expectedLastBlock.RangeEndAsInt(), lastBlock.EndNumber); }
private RangeBlockContext CreateBlockContext(BlockRequest blockRequest, RangeBlock rangeBlock, int forcedBlockQueueId = 0) { var attempt = rangeBlock.Attempt + 1; var createRequest = new BlockExecutionCreateRequest(new TaskId(blockRequest.ApplicationName, blockRequest.TaskName), blockRequest.TaskExecutionId, blockRequest.BlockType, rangeBlock.RangeBlockId, attempt); var blockExecutionId = _blockRepository.AddRangeBlockExecution(createRequest); var blockContext = new RangeBlockContext(_rangeBlockRepository, _taskExecutionRepository, blockRequest.ApplicationName, blockRequest.TaskName, blockRequest.TaskExecutionId, rangeBlock, blockExecutionId, forcedBlockQueueId.ToString()); return(blockContext); }
/// <summary> 将<seealso cref="Xrecord"/>对象中的数据刷新到内存中的静态类中 </summary> /// <param name="xrec">其值可以为 null,表示集合中一个数据都没有 </param> public static void FromXrecord_Blocks(Xrecord xrec) { RangeBlocks = new List <RangeBlock>(); if (xrec != null) { var buffs = xrec.Data.AsArray(); if (buffs == null || buffs.Length == 0) { return; } // try { var itemsCount = (int)buffs[0].Value; var fieldsCount = 6; var baseIndex = 1; for (int i = 0; i < itemsCount; i++) { var s = new RangeBlock( type: Utils.GetExtendedDataEnum <BlockType>(buffs[baseIndex]), startStation: (double)buffs[baseIndex + 1].Value, endStation: (double)buffs[baseIndex + 2].Value) { ConnectedBackStaion = (double)buffs[baseIndex + 3].Value, ConnectedFrontStaion = (double)buffs[baseIndex + 4].Value, Description = (string)buffs[baseIndex + 5].Value, }; // RangeBlocks.Add(s); baseIndex += fieldsCount; } } catch (Exception ex) { //MessageBox.Show($"刷新选项数据“{fields[index].Name}”出错。\r\n{ex.StackTrace}"); } } // }
/// <summary> /// Determines wehther the actual number is close to an expected value within a given within. /// </summary> /// <param name="check">The fluent check to be extended.</param> /// <param name="expected">The expected value.</param> /// <param name="within">The within.</param> /// <returns></returns> /// <exception cref="FluentCheckException"></exception> public static ICheckLink<ICheck<double>> IsCloseTo(this ICheck<double> check, Double expected, Double within) { var checker = ExtensibilityHelper.ExtractChecker(check); var range = new RangeBlock(expected, within); return checker.ExecuteCheck( () => { if (!range.IsInRange(checker.Value)) { var errorMessage = checker.BuildMessage("The {0} is outside the expected value range.").On(checker.Value).And.Expected(range).ToString(); throw new FluentCheckException(errorMessage); } }, checker.BuildMessage("The {0} is within the expected range, whereas it must not.").On(checker.Value).And.Expected(range).ToString()); }
protected override void ExtenderConstructor() { targetType = TargetType.AllFriendlies; ammoCost = 2; addedStipulationCard = new RangeBlock(); name = "Smokescreen"; description = "The user and all friendly characters gain a ranged block"; image = SpriteBase.mainSpriteBase.cloud; }
public RangeBlockerPrep() { placedStipulationCard = new RangeBlock(); name = "Range blocker"; description = "Play " + placedStipulationCard.name; image = SpriteBase.mainSpriteBase.crosshair; }
protected override void ExtenderConstructor() { targetType = TargetType.None; ammoCost = 1; addedStipulationCard = new RangeBlock(); name = "Defillade"; description = "Gain ranged block"; image = SpriteBase.mainSpriteBase.rock; }
protected override void ExtenderConstructor() { targetType = TargetType.SelectFriendlyOther; staminaCost = 1; addedStipulationCard = new RangeBlock(); name = "Covering Fire"; description = "Selected friendly character gains range block"; image = SpriteBase.mainSpriteBase.skull; }
protected override void ExtenderConstructor() { ammoCost = 1; targetType = TargetType.None; addedStipulationCard = new RangeBlock(); name = "Smoke Grenade"; description = "Gain ranged block"; image = SpriteBase.mainSpriteBase.lightning; }