public void as_string_and_to_string_are_equal() { var id = new SampleAggregateId(555); var asString = id.AsString(); var toString = id.ToString(); Assert.AreEqual(asString, toString); }
public void profile_snapshot_opt_out() { var sampleAggregateId = new SampleAggregateId(1); var aggregate = TestAggregateFactory.Create <SampleAggregate, SampleAggregate.State>(new SampleAggregate.State(), sampleAggregateId); aggregate.Create(); _repository.Save(aggregate, Guid.NewGuid(), null); int max = 20; for (int t = 1; t < max; t++) { aggregate.Touch(); _repository.Save(aggregate, Guid.NewGuid(), null); if (t == max - 5) { var snap = ((ISnapshotable)aggregate).GetSnapshot(); _eventStore.Advanced.AddSnapshot(new Snapshot("Jarvis", sampleAggregateId.AsString(), aggregate.Version, snap)); } } SnapshotsSettings.OptOut(typeof(SampleAggregate)); var sw = new Stopwatch(); sw.Start(); for (int c = 1; c <= 100; c++) { using (var repo = new RepositoryEx( _eventStore, _aggregateFactory, new ConflictDetector(), _identityConverter)) { var loaded = repo.GetById <SampleAggregate>(sampleAggregateId); } } sw.Stop(); SnapshotsSettings.ClearOptOut(); Debug.WriteLine("Read time {0} ms", sw.ElapsedMilliseconds); }
public void raise_exception_if_invariants_are_not_satisfied() { var sampleAggregateId = new SampleAggregateId(1); var aggregate = TestAggregateFactory.Create <SampleAggregate, SampleAggregate.State>(new SampleAggregate.State(), sampleAggregateId); aggregate.Create(); aggregate.InvalidateState(); try { _repository.Save(aggregate, new Guid("135E4E5F-3D65-43AC-9D8D-8A8B0EFF8501"), null); Assert.Fail("We expect an exception"); } catch (InvariantNotSatifiedException ex) { Assert.That(ex.AggregateId, Is.EqualTo(sampleAggregateId.AsString())); } catch (Exception ex) { Assert.Fail("We expect an exception of type InvariantNotSatifiedException but we catched " + ex.GetType().Name); } }