public void verifyThatOptionDependentValuesetsComparerCompareReturnsExpectedResults()
        {
            var comparer = new OptionComparer();

            Assert.AreEqual(0, comparer.Compare(null, null));

            Assert.AreEqual(1, comparer.Compare(null, this.optiona));

            Assert.AreEqual(-1, comparer.Compare(this.optiona, null));

            var comparisonab = comparer.Compare(this.optiona, this.optionb);

            Assert.AreEqual(1, comparisonab);

            var comparisonba = comparer.Compare(this.optionb, this.optiona);

            Assert.AreEqual(-1, comparisonba);

            var comparisonaa = comparer.Compare(this.optiona, this.optiona);

            Assert.AreEqual(0, comparisonaa);

            var comparisonbb = comparer.Compare(this.optionb, this.optionb);

            Assert.AreEqual(0, comparisonbb);
        }
Пример #2
0
        private async Task FinDataAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                _finOptionsData = new List <OptionData>();
                List <Option> options = null;

                // retrieve option list from database
                using (var ctx = new FinancialChartsContext())
                {
                    options = ctx.Option.ToList();
                }
                // sort the options by Strike values
                var strikeComparer = new OptionComparer();
                options.Sort(strikeComparer);

                foreach (var opt in options)
                {
                    var optionData = new OptionData(opt);
                    _finOptionsData.Add(optionData);
                }

                string jsonDataString = JsonConvert.SerializeObject(_finOptionsData);
                await _serverSentEventsService.SendEventAsync(jsonDataString);

                await Task.Delay(TimeSpan.FromSeconds(_interval), cancellationToken);
            }
        }
Пример #3
0
        public IEnumerable <IAssociationOption> ParseCommoditiesList(AssociationPostFilterFunctionParameters postParams)
        {
            var comparer = new OptionComparer();
            ISet <IAssociationOption> commodity = new SortedSet <IAssociationOption>();

            foreach (var resultset in postParams.Options)
            {
                AssociationOption result = new AssociationOption(resultset.Value, resultset.Label);
                result.Value = resultset.Value;
                if (resultset.Label == null || resultset.Label.IndexOf('-') == -1)
                {
                    result.Label = MISSING;
                    //commodity.Add(result);
                }
                else
                {
                    string[] arrTemp = resultset.Label.Split('-');
                    if (postParams.Association.Target == "component")
                    {
                        result.Label = (arrTemp.Length > 2) ? arrTemp[2] : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "system")
                    {
                        result.Label = arrTemp[0] + '-' + arrTemp[1];
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "module")
                    {
                        result.Label = (arrTemp.Length > 4) ? ModuleFieldValue(arrTemp) : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "item")
                    {
                        result.Label = (arrTemp.Length > 3) ? arrTemp[3] : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                }
            }

            return(commodity);
        }
        public void VerifyThatOptionsContainedInDifferentIterationsThrowsException()
        {
            var comparer = new OptionComparer();

            var iterationx = new Iteration(Guid.NewGuid(), null, null);
            var optionx    = new Option(Guid.NewGuid(), null, null);

            iterationx.Option.Add(optionx);

            var iterationy = new Iteration(Guid.NewGuid(), null, null);
            var optiony    = new Option(Guid.NewGuid(), null, null);

            iterationy.Option.Add(optiony);

            Assert.Throws <InvalidOperationException>(() => comparer.Compare(optionx, optiony));
        }
Пример #5
0
 public int CompareTo(string owner, string name)
 {
     return(OptionComparer.Compare(this, owner, name));
 }
Пример #6
0
 public int CompareTo(Option other)
 {
     return(OptionComparer.Compare(this, other));
 }