Esempio n. 1
0
        /// <summary>
        /// 手番がまわってきた
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="cards"></param>
        protected override IEnumerable <Card> _TurnCame(IPlayerContext ctx)
        {
            var tefuda = ctx.Deck.ToList();

            tefuda.Sort();
            if (ctx.GameContext.IsKakumei)
            {
                tefuda.Reverse();
            }
            int n = 1;

            if (ctx.GameContext.Ba.Any())
            {
                n = ctx.GameContext.Ba.Last().Count();
            }


            // 弱いカードから順番に出す。
            for (int i = 0; i < tefuda.Count - (n - 1); i++)
            {
                var          temp   = tefuda.GetRange(i, n);
                ICheckResult result = ctx.GameContext.Rule.CheckPutCards(ctx.GameContext, temp);
                if (result is CheckOK)
                {
                    Debug.WriteLine(string.Format("{0} {1}", Name, temp.ToCardsetString()));
                    return(temp);
                }
            }

            Debug.WriteLine(string.Format("{0} PASS", Name));
            return(null); // 出せるカードがないのでパス
        }
Esempio n. 2
0
        private void SendCheckResultToDataDog(ICheckResult checkResult, string[] tags)
        {
            string resultStatName = $"check.{checkResult.CheckName}.result";
            int    resultValue    = TranslateLevel(checkResult.Level);

            NotifyDataDogGauge(resultStatName, resultValue, tags);
        }
Esempio n. 3
0
 public EvaluateSubmit(ICheckResult checker, IUpdateStatsOnSubmit stats, ITranslate <Guid, TranslatedExpression> translator, IStore <DbChapter> chapters)
 {
     _checker    = checker;
     _stats      = stats;
     _translator = translator;
     _chapters   = chapters;
 }
Esempio n. 4
0
        public Violation(
            ICheckResult checkResult,
            IDocument document,
            object obj,
            ViolationLevel level             = ViolationLevel.Error,
            Dictionary <string, object> data = null)
        {
            CheckResult = checkResult;
            Document    = document;
            Object      = obj;
            Level       = level;

            Data.Add("Документ", Document);
            if (Document != Object)
            {
                Data.Add("Область исследования", Object);
            }

            if (data != null)
            {
                foreach (var dataItem in data)
                {
                    Data.Add(dataItem);
                }
            }
        }
Esempio n. 5
0
 public ProtocolData(ICheckResult result)
 {
     _data = new
     {
         Kind    = "Exception",
         Message = result.Message
     };
 }
Esempio n. 6
0
        private void SendIsHealthyToDataDog(ICheckResult checkResult, string[] tags)
        {
            var checkResultCheckName = checkResult.CheckName;

            string isHealthyStateName = $"check.{checkResultCheckName}.isHealthy";
            int    isHealthyValue     = Convert.ToInt32(checkResult.Level == NotificationLevel.Okay);

            NotifyDataDogGauge(isHealthyStateName, isHealthyValue, tags);
        }
Esempio n. 7
0
        public async Task RunAsync_SomeBucketsWithDocumentCountAboveThreshold_WarningNotification(NotificationLevel expectedLevel)
        {
            _bucketConfig2.SetupGet(x => x.BasicStats).Returns(new BasicStats {
                ItemCount = _aboveThreshold
            });

            ICheckResult result = await _target.RunAsync();

            Assert.AreEqual(expectedLevel, result.Level);
            _clusterService.Verify(x => x.GetClusterInfoAsync(), Times.Once);
        }
Esempio n. 8
0
        private void _assertCheckPutCardsIsNG(IEnumerable <Card> cards, ICheckResult result)
        {
            var ret = _rule.CheckPutCards(_ctx, cards);

            if (!(ret is CheckOK))
            {
                Assert.IsTrue(ret.Message.Contains(result.Message));
                return;
            }
            Assert.Fail("チェック通過 cards=" + cards.ToCardsetString());
        }
Esempio n. 9
0
        public async Task RunAsync_AllBucketsWithDocumentCountWithinThreshold_OkayNotification(NotificationLevel expectedLevel)
        {
            _bucketConfig2.SetupGet(x => x.BasicStats).Returns(new BasicStats {
                ItemCount = _belowThreshold
            });

            ICheckResult result = await _target.RunAsync();

            Assert.AreEqual(expectedLevel, result.Level);
            Assert.IsTrue(result.RenderPlainText().Contains("Bucket document count within expected range"));
            _clusterService.Verify(x => x.GetClusterInfoAsync(), Times.Once);
        }
Esempio n. 10
0
        public async Task RunAsync_ClusterApiCannotBeAccessed_CriticalNotification(NotificationLevel expectedLevel)
        {
            var msg = "Cannot Access Cluster";
            var ex  = new CannotAccesClusterInfoException(msg, new Exception());

            _clusterService.Setup(x => x.GetClusterInfoAsync()).ThrowsAsync(ex);

            ICheckResult result = await _target.RunAsync();

            Assert.AreEqual(expectedLevel, result.Level);
            Assert.IsTrue(result.RenderPlainText().Contains(msg));
            _clusterService.Verify(x => x.GetClusterInfoAsync(), Times.Once);
        }
        public static CheckResultEntity Create(ICheckResult src)
        {
            var partitionKey = src.Date.ToString("yyyyMMdd_HHmm");
            var rowKey       = DateTime.UtcNow.ToString("yyyyMMdd_HHmmss.fff");

            return(new CheckResultEntity
            {
                PartitionKey = partitionKey,
                RowKey = rowKey,
                Date = src.Date,
                DateFrom = src.DateFrom,
                DateTo = src.DateTo,
                Comments = src.Comments,
                Timestamp = DateTime.UtcNow
            });
        }
        private void AddResult(ICheckResult result)
        {
            //find id result.Check
            var checkId = (long)new SQLiteCommand($"SELECT Id FROM 'Check' c WHERE c.Name = '{result.Check.Name}';", _connection)
                          .ExecuteScalar();
            var checkResultId = AddCheckResult(checkId);

            foreach (var violation in result.Violations)
            {
                //add violation
                var violationId = AddViolation(checkResultId, violation);
                foreach (var data in violation.Data)
                {
                    //add result.Violations...Data
                    AddViolationData(violationId, data.Key, data.Value);
                }
            }
        }
 public async Task AddAsync(ICheckResult entity)
 {
     await _tableStorage.InsertAsync(CheckResultEntity.Create(entity));
 }
Esempio n. 14
0
 public CheckedObject(object obj, ICheckResult checkResult)
 {
     Object      = obj;
     CheckResult = checkResult;
 }