public void ConventionRegisteredEvents_are_applied() { var person = AggregateFactory.BuildEmpty <ProgrammerAggregate>(); var personCreated = new PersonCreated(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); ((IAggregate)person).Apply(personCreated); Assert.Equal(personCreated.PersonId, person.PersonId); }
public void AggregateCommandsHandlerThroughput() { T aggregate = AggregateFactory.BuildEmpty <T>(); foreach (var cmd in _commndsToExecute) { aggregate = CommandsHandler.ExecuteAsync(aggregate, cmd) .Result; _counter.Increment(); } }
public void Given_created_event() { var processId = Guid.NewGuid().ToString(); var softwareProgrammingState = new SoftwareProgrammingState(processId, nameof(SoftwareProgrammingProcess.Sleeping)); var aggregate = AggregateFactory.BuildEmpty <ProcessStateAggregate <SoftwareProgrammingState> >(processId); aggregate.ApplyEvents(new ProcessManagerCreated <SoftwareProgrammingState>(softwareProgrammingState, processId)); //Then_State_is_taken_from_event() Assert.Equal(softwareProgrammingState, aggregate.State); //Then_Id_is_taken_from_event() Assert.Equal(processId, aggregate.Id); }
public void Given_created_and_message_received_and_transitioned_event() { var processId = Guid.NewGuid().ToString(); var softwareProgrammingState = new SoftwareProgrammingState(processId, nameof(SoftwareProgrammingProcess.Sleeping)); var aggregate = AggregateFactory.BuildEmpty <ProcessStateAggregate <SoftwareProgrammingState> >(processId); aggregate.ApplyEvents(new ProcessManagerCreated <SoftwareProgrammingState>(softwareProgrammingState, processId), new ProcessReceivedMessage <SoftwareProgrammingState>(processId, softwareProgrammingState, Guid.NewGuid().ToString())); Assert.Equal(softwareProgrammingState, aggregate.State); }
public void Given_order_created() { var order = AggregateFactory.BuildEmpty <Order>(); var created = order.ApplyEvent(new OrderCreated(Guid.NewGuid(), 123, Guid.NewGuid())); // Order_items_are_empty() Assert.Empty(order.Items); //Order_receives_id() Assert.Equal(created.SourceId, order.Id); //Order_receives_number() Assert.Equal(created.Number, order.Number); //rder_status_is_created() Assert.Equal(OrderStatus.Created, order.Status); //User_receives_user() Assert.Equal(created.User, order.UserId); }
public void When_adding_new_item() { var aggregate = AggregateFactory.BuildEmpty <Order>(); aggregate.ApplyEvents(new OrderCreated(aggregate.Id, 1, Guid.NewGuid()), new ItemAdded(aggregate.Id, Guid.NewGuid(), 2, new Money(100), 1)); var initialSum = aggregate.TotalPrice; var initialItemsCount = aggregate.Items.Count; var itemAddedEventB = aggregate.ApplyEvent(new ItemAdded(aggregate.Id, Guid.NewGuid(), 1, new Money(50), 2)); //Order_items_contains_new_one_as_separate_item() Assert.NotEmpty(aggregate.Items.Where(i => i.Quantity == itemAddedEventB.Quantity && i.Sku == itemAddedEventB.Sku && i.TotalPrice == itemAddedEventB.TotalPrice)); //Order_items_count_is_increased_by_one() Assert.Equal(initialItemsCount + 1, aggregate.Items.Count); //Order_total_sum_is_increased_by_new_item_total() Assert.Equal(itemAddedEventB.TotalPrice, aggregate.TotalPrice - initialSum); }
public Account_hydration_tests() { Account = AggregateFactory.BuildEmpty <Account>(); _created = Account.ApplyEvent(new Fixture().Create <AccountCreated>()); _initialAmountEvent = Account.ApplyEvent(new AccountReplenish(_created.SourceId, Guid.NewGuid(), new Money(100))); }