예제 #1
0
        public async Task <IActionResult> SearchCalculations(string specificationId,
                                                             CalculationType calculationType,
                                                             PublishStatus?status,
                                                             string searchTerm,
                                                             int?page)
        {
            Guard.IsNullOrWhiteSpace(specificationId, nameof(specificationId));

            Dictionary <string, string[]> filters = new Dictionary <string, string[]>
            {
                { "specificationId", new [] { specificationId } },
                { "calculationType", new [] { calculationType.ToString() } }
            };

            if (status.HasValue)
            {
                filters.Add("status", new [] { status.Value.ToString() });
            }

            return(await SearchCalculations(new SearchModel
            {
                SearchMode = Models.Search.SearchMode.All,
                FacetCount = 50,
                SearchTerm = searchTerm,
                Filters = filters,
                PageNumber = page.GetValueOrDefault(1),
                Top = 50
            }));
        }
예제 #2
0
        public void ControllerErrorPayloadTooLargeOrSmall(CalculationType calculationType)
        {
            // arrange
            var calcFactory = new CalculationFactory();

            // act
            var calc = calcFactory.Build(calculationType);

            // assert
            calc.GetType().Name.Should().Contain(calculationType.ToString());
        }
예제 #3
0
 public Dictionary <VisibilityresultSummaryItemsEnum, string> SummaryToString()
 {
     return(new Dictionary <VisibilityresultSummaryItemsEnum, string>
     {
         { VisibilityresultSummaryItemsEnum.Type, CalculationType.ToString() },
         { VisibilityresultSummaryItemsEnum.Name, ResultName },
         { VisibilityresultSummaryItemsEnum.Surface, SourceSurfaceame },
         { VisibilityresultSummaryItemsEnum.ObservationPoints, ObservationPoints == null ? string.Empty : string.Join(", ", ObservationPoints) },
         { VisibilityresultSummaryItemsEnum.ObservationObjects, ObservationObjects == null ? string.Empty : string.Join(", ", ObservationObjects) },
         { VisibilityresultSummaryItemsEnum.CalculateCommonVisibilityResult, CommonVisibilityResult.ToString() },
         { VisibilityresultSummaryItemsEnum.CalculateSeparatedPoints, SeparatedVisibilityResult.ToString() },
         { VisibilityresultSummaryItemsEnum.TrimCalculatedSurface, TrimVisibilityResult.ToString() },
         { VisibilityresultSummaryItemsEnum.ConvertToPolygon, ConvrtToPolygonResult.ToString() },
     });
 }
예제 #4
0
        private void TestRun(CalculationType calcType, InsertionType insertType, int runCount, StreamWriter sw)
        {
            sw.Write($"{calcType.ToString()},{insertType.ToString()},");
            var iqmm     = new IncrementalIQMManager(PerformanceTestInputFilePath, calcType, insertType);
            var runtimes = new List <double>();

            for (var i = 0; i < runCount; i++)
            {
                var runtime = iqmm.Execute();
                runtimes.Add(runtime);
                sw.Write($"{runtime},");
            }
            var avgRuntime = runtimes.Sum() / runtimes.Count;

            sw.WriteLine(avgRuntime);
        }
예제 #5
0
        public static void Write()
        {
            config.SetBool("PP Helper", "showInfo", showInfo);
            config.SetFloat("PP Helper", "defaultAcc", defaultAcc);
            config.SetBool("PP Helper", "ppTop", ppTop);
            config.SetFloat("PP Helper", "accIncrement", accIncrement);
            config.SetFloat("PP Helper", "starRange", starRange);
            config.SetString("PP Helper", "starAccChoice", starAccChoice.ToString());
            config.SetInt("PP Helper", "numberOfScores", numberOfScores);
            config.SetBool("PP Helper", "accOverride", accOverride);
            config.SetBool("PP Helper", "autoUpdate", autoUpdate);
            config.SetBool("PP Helper", "playHistory", playHistory);
            config.SetString("PP Helper", "sortMethod", sortMethod.ToString());

            config.SetBool("PP Helper", "ignoreNoFail", ignoreNoFail);
            config.SetBool("PP Helper", "hideOnStart", hideOnStart);
            config.SetInt("PP Helper", "decimalPrecision", decimalPrecision);
        }
예제 #6
0
 public static Uri PriceHistorical(
     string fsym,
     IEnumerable <string> tsyms,
     IEnumerable <string> markets,
     DateTimeOffset ts,
     CalculationType?calculationType,
     bool?tryConversion)
 {
     return(new Uri(MinApiEndpoint, "pricehistorical").ApplyParameters(
                new Dictionary <string, string>
     {
         { nameof(fsym), fsym },
         { nameof(tsyms), tsyms.ToJoinedList() },
         { nameof(ts), ts.ToUnixTime().ToString(CultureInfo.InvariantCulture) },
         { nameof(markets), markets?.ToJoinedList() },
         { nameof(calculationType), calculationType?.ToString("G") },
         { nameof(tryConversion), tryConversion?.ToString() }
     }));
 }
예제 #7
0
 public static Uri DayAveragePrice(
     string fsym,
     string tsym,
     string e,
     DateTimeOffset?toTs,
     CalculationType?avgType,
     int?UTCHourDiff,
     bool?tryConversion)
 {
     return(new Uri(MinApiEndpoint, "dayAvg").ApplyParameters(
                new Dictionary <string, string>
     {
         { nameof(fsym), fsym },
         { nameof(tsym), tsym },
         { nameof(e), e },
         { nameof(toTs), toTs?.ToString() },
         { nameof(avgType), avgType?.ToString() },
         { nameof(UTCHourDiff), UTCHourDiff?.ToString() },
         { nameof(tryConversion), tryConversion?.ToString() },
     }));
 }
        public async Task GetCalculationCircularDependencies_ApiReturnsOk_ResponseHasApiObject()
        {
            const string          CalculationId   = "CalculationId";
            const string          CalculationName = "CalculationName";
            const CalculationType CalculationType = Common.ApiClient.Graph.Models.CalculationType.Additional;
            const string          FundingStream   = "FundingStream";
            const string          SpecificationId = "SpecificationId";

            IEnumerable <Entity <Calculation> > calculationEntities = new List <Entity <Calculation> >
            {
                new Entity <Calculation>
                {
                    Node = new Calculation
                    {
                        CalculationId   = CalculationId,
                        CalculationName = CalculationName,
                        CalculationType = CalculationType,
                        FundingStream   = FundingStream,
                        SpecificationId = SpecificationId,
                    }
                }
            };

            GraphCalculationService graphCalculationService = CreateGraphCalculationService();

            GivenGetCalculationCircularDependencies(HttpStatusCode.OK, calculationEntities);

            IActionResult actionResult = await graphCalculationService.GetCalculationCircularDependencies(SpecificationId);

            actionResult
            .Should()
            .NotBeNull()
            .And
            .BeOfType <OkObjectResult>();

            OkObjectResult okObjectResult = actionResult as OkObjectResult;

            okObjectResult
            .Value
            .Should()
            .NotBeNull()
            .And
            .BeOfType <List <GraphCalculationEntityViewModel <GraphCalculationViewModel> > >();

            List <GraphCalculationEntityViewModel <GraphCalculationViewModel> > actualCalculationEntities
                = okObjectResult.Value as List <GraphCalculationEntityViewModel <GraphCalculationViewModel> >;

            actualCalculationEntities
            .Count()
            .Should()
            .Be(calculationEntities.Count());

            actualCalculationEntities
            .FirstOrDefault()
            .Should()
            .NotBeNull();

            GraphCalculationEntityViewModel <GraphCalculationViewModel> firstCalculationEntity
                = actualCalculationEntities.FirstOrDefault();

            firstCalculationEntity
            .Node
            .Should()
            .NotBeNull();

            GraphCalculationViewModel firstCalculationNode = firstCalculationEntity.Node;

            firstCalculationNode
            .CalculationId
            .Should()
            .Be(CalculationId);

            firstCalculationNode
            .CalculationName
            .Should()
            .Be(CalculationName);

            firstCalculationNode
            .CalculationType
            .Should()
            .Be(CalculationType.ToString());

            firstCalculationNode
            .SpecificationId
            .Should()
            .Be(SpecificationId);

            firstCalculationNode
            .FundingStream
            .Should()
            .Be(FundingStream);
        }
예제 #9
0
 public override string ToString()
 {
     return("CalculationType=" +
            CalculationType.ToString() + ",FirstNumber=" + FirstNumber + ",SecondNumber" + SecondNumber);
 }
예제 #10
0
 public override string ReturnInputText(double valOne, double valTwo, CalculationType calcType)
 {
     return(string.Format(@"{0}{1}{2}=Cannot be calculated due to:", valOne, calcType.ToString(), valTwo) + @"{3}");
 }
예제 #11
0
 public virtual string ReturnInputText(double valOne, double valTwo, CalculationType calcType)
 {
     return(string.Format(@"{0}{1}{2}", valOne, calcType.ToString(), valTwo));
 }