Example #1
0
        public async Task Handle(IEventWrapper <ICurveCalculated> wrapper, CancellationToken cancellationToken)
        {
            var @event = wrapper.Content;

            var asOfDate = @event.AsOfDate;

            var recipe = (await _recipeRepository.Single(x => x.Id == @event.CurveRecipeId)) ?? new RecipeDto
            {
                Id   = @event.CurveRecipeId.NonEmpty(),
                Name = "unknown"
            };

            var dto = await _dtoRepository.Single(x => x.AsOfDate == asOfDate);

            if (dto == null)
            {
                dto = new Dto
                {
                    Id       = NonEmpty.Guid(),
                    AsOfDate = asOfDate,
                    Recipes  = new RecipeDto[] { recipe }
                };

                await _dtoRepository.Insert(dto);
            }

            else
            {
                var recipes = dto.Recipes.ToList();
                recipes.Add(recipe);
                dto.Recipes = recipes;

                await _dtoRepository.Update(dto);
            }
        }
Example #2
0
        public void AddUndoItem(IUndoItem undoEvent)
        {
            if (Working)
            {
                return;
            }

            bool emptyBefore = (_batch?.Count ?? 0) == 0 && !_undoEvents.Any();

            if (_batch != null)
            {
                _batch.Add(undoEvent);
            }
            else
            {
                ClearRedoHistory();
                _undoEvents.Push(undoEvent);
                if (_undoEvents.Count > MAX_UNDO_ITEMS)
                {
                    // XXX: we throw away the current item? this should be a Dequeue so we can pop the front
                    _undoEvents.Pop();
                }
            }

            if (emptyBefore)
            {
                // no longer empty
                NonEmpty?.Invoke(this, EventArgs.Empty);
            }
        }
        public void ParseEnum_Should_ReturnEnum(
            string value,
            NonEmpty expected)
        {
            var actual = EnumUtilities.ParseEnum(value, NonEmpty.Unknown);

            actual.Should().Be(expected);
        }
        public void InitializationNull()
        {
            NonEmpty AxisItem = new NonEmpty(null);

            Assert.Throws(Is.TypeOf <MDXException>()
                          .And.Message.EqualTo(MDXTextUtil.GetMessageErrorBaseNotInit(AxisItem)),
                          () => AxisItem.Build());
        }
        public void GetDescription_Should_ReturnOne_With_Expression(
            NonEmpty value,
            bool readAttribute,
            string expected)
        {
            var actual = value.GetDescription(readAttribute);

            actual.Should().Be(expected);
        }
Example #6
0
        public void UT_MarketCurve_AddCurvePoint_happy_flow()
        {
            var id          = Guid.NewGuid();
            var tenor       = Tenor.FRA10x16;
            var instrument  = new Instrument(NonEmpty.Guid(), Vendor.Bloomberg);
            var dateLag     = new DateLag(-1);
            var priceType   = PriceType.BIDPRICE;
            var isMandatory = false;

            Given(MarketCurveCreated(Country.GB, CurveType.ECB))
            .When(c => c.AddCurvePoint(tenor, instrument, dateLag, priceType, isMandatory))
            .Then(CurvePointAdded(tenor, instrument.Id, dateLag.Value, isMandatory, priceType));
        }
Example #7
0
        public async Task Handle(IEventWrapper <ICurveCalculated> @event, CancellationToken cancellationToken)
        {
            var asOfDate = @event.Content.AsOfDate;

            var existingDto = await _readModelRepository.Single(x => x.AsOfDate == asOfDate);

            if (existingDto != null)
            {
                var dto = new Dto
                {
                    Id       = NonEmpty.Guid(),
                    AsOfDate = asOfDate
                };

                await _readModelRepository.Insert(dto);
            }
        }
Example #8
0
        public void CloseBatch()
        {
            if (_batch == null)
            {
                return;
            }

            if (_batch.Count > 0)
            {
                bool emptyBefore = !_undoEvents.Any();
                _undoEvents.Push(_batch);
                if (emptyBefore)
                {
                    // no longer empty
                    NonEmpty?.Invoke(this, EventArgs.Empty);
                }
            }
            _batch = null;
        }
Example #9
0
        /// <summary>
        /// Rollback the last undone command.
        /// </summary>
        public void Redo()
        {
            if (!CanRedo)
            {
                return;
            }

            Working = true;
            IUndoItem redo = _redoEvents.Pop();

            redo.Do();
            bool emptyBefore = !_undoEvents.Any();

            _undoEvents.Push(redo);
            Working = false;
            if (emptyBefore)
            {
                NonEmpty?.Invoke(this, EventArgs.Empty);
            }
        }
Example #10
0
        public async Task Handle(IEventWrapper <ICurveCalculated> wrapper, CancellationToken cancellationToken)
        {
            var @event = wrapper.Content;

            var recipe = (CurveRecipe?)await _db.FindAsync <CurveRecipe>(@event.CurveRecipeId);

            _db.Add(new Dto
            {
                Id              = wrapper.AggregateId,
                AsAtDate        = wrapper.Timestamp.ToDateTimeUtc(),
                AsOfDate        = @event.AsOfDate,
                CurveRecipeId   = @event.CurveRecipeId.NonEmpty(),
                CurveRecipeName = recipe?.Name,
                Points          = @event.Points.Select(p => new Point
                {
                    Id       = NonEmpty.Guid(),
                    Currency = p.Currency,
                    Maturity = p.Maturity,
                    Value    = p.Value
                }).ToImmutableArray()
            });
        }
        public void InitializationOk()
        {
            NonEmpty AxisItem = new NonEmpty(MDXTextUtil.GetMoqMDXAxisItem());

            Assert.AreEqual("NON EMPTY { " + MDXTextUtil.GetDummyMember() + " }", AxisItem.Build());
        }
 public void GetEnumDescription_Should_ReturnDEscriptionAttribute_When_Available(NonEmpty value, string expected)
 {
     value.GetEnumDescription().Should().Be(expected);
 }
Example #13
0
 public Backtrace(NonEmpty <ImmutableList <BacktraceElem> > elements)
 {
     this.elements = elements;
 }
Example #14
0
 public static A random <C, A>(this NonEmpty <C> list, ref Rng rng)
     where C : IReadOnlyList <A>
 =>
 list.a[rng.nextIntInRange(new Range(0, list.a.Count - 1), out rng)];
Example #15
0
 public static A random <A>(this NonEmpty <ImmutableArray <A> > list, ref Rng rng) =>
 random <ImmutableArray <A>, A>(list, ref rng);