public void Apply_KeepsHighestVersion() { const int version = 420; IAggregate aggregate = new TestAggregate(); var event1 = new MockEvent { Version = version }; var event2 = new MockEvent { Version = version - 69 }; aggregate.Apply(event1); aggregate.Apply(event2); Assert.Equal(version, aggregate.Version); }
public void Can_apply_supported_event_to_aggregate() { var aggregate = new TestAggregate(); Assert.AreEqual(0, aggregate.Number); aggregate.Apply(new NumberIncreased(2)); Assert.AreEqual(2, aggregate.Number); }
public void Apply_SetsVersion() { const int version = 69; IAggregate aggregate = new TestAggregate(); var @event = new MockEvent { Version = version }; aggregate.Apply(@event); Assert.Equal(version, aggregate.Version); }
public void Update_updates_the_aggregate_in_mongo_collection() { //Given var testAggregate = new TestAggregate(1); Collection.InsertMany(new[] { testAggregate, /*noise*/ new TestAggregate(666) }); //When Collection.Find(aggregate => aggregate.Id == testAggregate.Id).Count().ShouldBe(1); testAggregate.Apply(new NumberChanged(999)); _repository.Update(testAggregate); var result = Collection.Find(aggregate => aggregate.Id == testAggregate.Id).Single(); //Then result.Id.ShouldBe(testAggregate.Id); result.Number.ShouldBe(testAggregate.Number); }