public void ApplyHistory_NullCollection_ShouldThrowException() { // Arrange EventAggregate eventAggregate = new FakeEventAggregate(); // Act, Assert Assert.Throws <ArgumentNullException>(() => eventAggregate.ApplyHistory(null)); }
public void ApplyHistory_WithNullObject_ShouldThrowException() { // Arrange IEnumerable <EventWithGuidKey> historyEvents = new EventWithGuidKey[] { null }; EventAggregate eventAggregate = new FakeEventAggregate(); // Act, Assert Assert.Throws <ArgumentNullException>(() => eventAggregate.ApplyHistory(historyEvents)); }
public void ApplyHistory_WithNotSupportedEventType_ShouldThrowException() { // Arrange EventWithGuidKey deletedEvent = new FakeDeletedEvent(Guid.NewGuid(), 1); IEnumerable <EventWithGuidKey> historyEvents = new[] { deletedEvent }; EventAggregate eventAggregate = new FakeEventAggregate(); // Act, Assert Assert.Throws <NotSupportedException>(() => eventAggregate.ApplyHistory(historyEvents)); }
public void ApplyHistory_WithNotEmptyEventHistory_ShouldApplyChanges() { // Arrange Guid eventAggregateId = Guid.NewGuid(); EventWithGuidKey createdEvent = new FakeCreatedEvent(eventAggregateId, 1); IEnumerable <EventWithGuidKey> historyEvents = new [] { createdEvent }; EventAggregate eventAggregate = new FakeEventAggregate(); // Act Guid beforeChangesId = eventAggregate.EntityId; eventAggregate.ApplyHistory(historyEvents); // Assert Assert.NotEqual(eventAggregateId, beforeChangesId); Assert.Equal(eventAggregateId, eventAggregate.EntityId); }