コード例 #1
0
        public async Task GetDeploymentsWithDeviceStatusTest()
        {
            // Arrange
            var configuration = this.CreateConfiguration(0, true);
            var deploymentId  = configuration.Id;

            this.registry.Setup(r => r.GetConfigurationAsync(deploymentId)).ReturnsAsync(configuration);

            IQuery queryResult = new ResultQuery(3);

            this.registry.Setup(r => r.CreateQuery(It.IsAny <string>())).Returns(queryResult);

            // Act
            var returnedDeployment = await this.deployments.GetAsync(deploymentId);

            var deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;

            // Assert
            Assert.Null(deviceStatuses);

            returnedDeployment = await this.deployments.GetAsync(deploymentId, true);

            deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;
            Assert.Equal(3, deviceStatuses.Count);
        }
コード例 #2
0
        public async Task <Result> Handle(CustomersQuery request, CancellationToken cancellationToken)
        {
            Result result = new Result();

            var pagedCustomers = await
                                 _customerRepository.GetPagedCustomers(request.Name, request.Cpf, request.Email, request.Page, request.PageSize);

            if (pagedCustomers.Data.Count > 0)
            {
                result = new ResultQuery <List <CustomerDto> >
                             (pagedCustomers.Data,
                             pagedCustomers.Page,
                             pagedCustomers.PageSize,
                             pagedCustomers.TotalItems,
                             pagedCustomers.TotalPages
                             );
            }
            else
            {
                result = new ResultQuery <List <CustomerDto> >();
                result.AddNotification(new FluentValidator.Notification("Query", "Nenhum resultado foi encontrado para os parâmetros de busca informados."));
            }

            return(result);
        }
コード例 #3
0
        public ActionResult TestPage(FormCollection fc)
        {
            var countRight = 0;
            var countWrong = 0;
            var error      = "";

            foreach (var key in fc.AllKeys)
            {
                if (key.Contains("rb"))
                {
                    try
                    {
                        var         value         = fc[key];
                        ResultQuery resultQuery   = ResultsService.AddAnswer(value, Session["Login"].ToString());
                        bool        isAnswerRight = ResultsService.IsAnswerRight(value);
                        if (isAnswerRight)
                        {
                            countRight++;
                        }
                        else
                        {
                            countWrong++;
                        }
                    }
                    catch (Exception ex)
                    {
                        Nlogger.Error("Error in TestPage save result. " + ex.Message);
                    }
                }
            }
            ViewBag.results = new ResultDto {
                CountRight = countRight, CountWrong = countWrong, Error = error
            };
            return(View());
        }
コード例 #4
0
        public object GetResults(ResultQuery query)
        {
            var results = new List <HandResult>();

            _vp.SetHand(Card.Hand(query.Hand.ToArray()));

            var holdCards = Card.Hand(query.HeldCards.ToArray());

            for (var i = 0; i < query.Hands; i++)
            {
                results.Add(_vp.ResolveHand(holdCards, query.Bet, query.PayTable));
            }

            var transformedResults = results.Select(r =>
                                                    new TransformedResult
            {
                Hand       = r.Hand.Select(c => c.ToString()).ToList(),
                PayLineHit = r.PayLineHit,
                Payout     = r.Payout
            }).ToList();

            foreach (var result in transformedResults)
            {
                var reorderedHand = new List <string>();
                var i             = 0;
                for (var j = 0; j < 5; j++)
                {
                    if (query.HeldCards.Contains(query.Hand[j]))
                    {
                        reorderedHand.Add(query.Hand[j]);
                    }
                    else
                    {
                        if (query.Hand[j] != result.Hand[i])
                        {
                            reorderedHand.Add(result.Hand[i]);
                        }
                        i++;
                    }
                }
                result.Hand = reorderedHand;
            }

            var correctPlay = _player.GetHolds(Card.Hand(query.Hand.ToArray()));


            return(new
            {
                Hand = transformedResults[0],
                Results = transformedResults.Skip(1),
                CreditsPayed = results.Sum(r => r.Payout),
                CorrectPlay = correctPlay.Select(i => query.Hand[i]),
                CorrectPlayIndexes = correctPlay
            });
        }
コード例 #5
0
        public object CheckHand(ResultQuery query)
        {
            var result = _vp.ResolveHand(Card.Hand(query.Hand.ToArray()), query.Bet, query.PayTable);

            return(new TransformedResult
            {
                Hand = result.Hand.Select(c => c.ToString()).ToList(),
                PayLineHit = result.PayLineHit,
                Payout = result.Payout
            });
        }
コード例 #6
0
        public async Task GetDeploymentsWithDeviceStatusTest()
        {
            // Arrange
            var configuration = this.CreateConfiguration(0, true);
            var deploymentId  = configuration.Id;

            this.registry.Setup(r => r.GetConfigurationAsync(deploymentId)).ReturnsAsync(configuration);

            IQuery queryResult = new ResultQuery(3);

            this.registry.Setup(r => r.CreateQuery(It.IsAny <string>())).Returns(queryResult);

            this.tenantHelper.Setup(e => e.GetRegistry()).Returns(this.registry.Object);

            var deploymentStorageData = this.CreateDeploymentStorageData(0);

            this.storageAdapterClient.Setup(r => r.GetAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(deploymentStorageData);

            // Act
            var returnedDeployment = await this.deployments.GetAsync(deploymentId, true);

            var deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;

            Assert.Equal(3, deviceStatuses.Count);

            // Assert
            returnedDeployment = await this.deployments.GetAsync(deploymentId);

            deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;
            Assert.Null(deviceStatuses);

            deploymentStorageData = this.CreateDeploymentStorageData(0, false);
            this.storageAdapterClient.Setup(r => r.GetAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(deploymentStorageData);

            returnedDeployment = await this.deployments.GetAsync("deployment0", false, false);

            deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;
            Assert.Null(deviceStatuses);

            returnedDeployment = await this.deployments.GetAsync("deployment0", true, false);

            deviceStatuses = returnedDeployment.DeploymentMetrics.DeviceStatuses;
            Assert.NotNull(deviceStatuses);
        }