public void ExecuteCommand_PlayChanges() { // init const int currentVersion = 0; const int expectedVerstion = currentVersion + 1; var model = new StubModel { AggregateId = new AggregateId<StubModel>("1"), BoolVal = false, LatestVersion = currentVersion }; var expected = new StubChangeEvent(model.AggregateId, true) { Version = expectedVerstion }; var command = new StubPostCommand(true); // run var actualEvt = command.ExecuteOn(model); Assert.AreEqual(expected.Id.Value, actualEvt.Id.Value); Assert.AreEqual(expected.Version, actualEvt.Version); Assert.AreEqual(expectedVerstion, actualEvt.Version); var player = new Player<StubModel>(); player.PlayFor(model, actualEvt); Assert.AreEqual(true, model.BoolVal); Assert.AreEqual(expectedVerstion, model.LatestVersion); Assert.AreEqual(actualEvt.Version, model.LatestVersion); player.PlayFor(model, actualEvt); Assert.AreEqual(true, model.BoolVal); Assert.AreEqual(expectedVerstion, model.LatestVersion); Assert.AreEqual(actualEvt.Version, model.LatestVersion); }
public void PerformCommand_ExceptionOnValidationError() { // init var command = new StubPostCommand(false); var model = new StubModel { AggregateId = new AggregateId<StubModel>("1"), BoolVal = false }; // run Assert.Throws<Exception>(() => command.ExecuteOn(model)); }