public void Add_NullObject_ShouldThrowException() { // Arrange IEventStore <Guid, Event <Guid> > eventStore = CreateDummyEventStore(); IEventSourcedRepository <FakeEventAggregate, Guid> repository = new MemoryEventAggregateRepository <FakeEventAggregate>(eventStore); // Act, Assert Assert.ThrowsAsync <ArgumentNullException>(() => repository.SaveAsync(null)); }
public async void Add_FakeObject_ShouldBeSaved() { // Arrange Mock <IEventStore <Guid, Event <Guid> > > eventStoreMock = CreateEventStoreMock(); IEventStore <Guid, Event <Guid> > eventStore = eventStoreMock.Object; FakeEventAggregate fakeEventAggregate = CreateDirtyFake(Guid.NewGuid()); IEventSourcedRepository <FakeEventAggregate, Guid> repository = new MemoryEventAggregateRepository <FakeEventAggregate>(eventStore); // Act bool result = await repository.SaveAsync(fakeEventAggregate); // Assert Assert.True(result); eventStoreMock.Verify(m => m.SaveEvents(It.IsAny <Guid>(), It.IsAny <IReadOnlyCollection <Event <Guid> > >()), Times.Once); }