Ejemplo n.º 1
0
        public void StockAggregateQuotationsShouldAlwaysBeInitialized()
        {
            var aggregate = new StockAggregate();
            var snapshot  = aggregate.GetSnapshot() as StockAggregateSnapshot;

            snapshot.Quotations.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        public void StockAggregateQuotationShouldBeAdded()
        {
            var quotation = new Quotation(DateTime.Parse("2016-01-01 00:00:00"), DateTime.Now, 5, 10, 10, 5);

            var aggregate = new StockAggregate();

            aggregate.AddOrChangeQuotation(quotation);
            var snapshot = aggregate.GetSnapshot() as StockAggregateSnapshot;

            snapshot.Quotations.Should().NotBeNull();
            snapshot.Quotations.Should().HaveCount(1);
            snapshot.Quotations.FirstOrDefault().Open.Should().Be(5);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        /// <exception cref="DomainValidationException">Thrown if validation fails</exception>
        public void Execute(StockAddCommand command)
        {
            //TODO: Validate if name of stock and wkn is unique bei gleichem type ->Exception: Resources.Validation_StockNameExists
            //TODO: Validate if name, wkn and type is not empty

            var aggregate = new StockAggregate(
                command.AggregateId,
                command.Name,
                command.Wkn,
                command.Type,
                command.LongShort,
                new List <IQuotation>());

            _repository.Save(aggregate, -1);
        }
Ejemplo n.º 4
0
        public void StockAggregateQuotationsShouldBeUpdatedIfQuotationAlreadyExists()
        {
            var quotation    = new Quotation(DateTime.Parse("2016-01-01 00:00:00"), DateTime.Now, 5, 10, 10, 5);
            var quotationNew = new Quotation(DateTime.Parse("2016-01-01 00:00:00"), DateTime.Now.AddDays(1), 55, 10, 10, 5);

            var aggregate = new StockAggregate();

            aggregate.AddOrChangeQuotation(quotation);
            aggregate.AddOrChangeQuotation(quotationNew);
            var snapshot = aggregate.GetSnapshot() as StockAggregateSnapshot;

            snapshot.Quotations.Should().NotBeNull();
            snapshot.Quotations.Should().HaveCount(1);
            snapshot.Quotations.FirstOrDefault().Open.Should().Be(55);
        }