public async Task Delete_deletes_Memento_entity() { // Arrange var sourceId = Guid.NewGuid(); var memento = new FakeUserMemento(); var sut = new SqlMementoStore( () => new MementoStoreDbContext(_dbContextOptions), new JsonMessageSerializer()); await sut.Save <FakeUser>(sourceId, memento, default); // Act await sut.Delete <FakeUser>(sourceId, default); // Assert using (var db = new MementoStoreDbContext(_dbContextOptions)) { bool actual = await db .Mementoes .Where(m => m.AggregateId == sourceId) .AnyAsync(); actual.Should().BeFalse(); } }
public async Task Delete_deletes_Memento_entity() { var sourceId = Guid.NewGuid(); FakeUserMemento memento = _fixture.Create <FakeUserMemento>(); await _sut.Save <FakeUser>(sourceId, memento, CancellationToken.None); await _sut.Delete <FakeUser>(sourceId, CancellationToken.None); using (var db = new DataContext()) { bool actual = await db .Mementoes .Where(m => m.AggregateId == sourceId) .AnyAsync(); actual.Should().BeFalse(); } }
public void Delete_does_not_fail_even_if_Memento_entity_does_not_exist() { // Arrange var sourceId = Guid.NewGuid(); var sut = new SqlMementoStore( () => new MementoStoreDbContext(_dbContextOptions), new JsonMessageSerializer()); // Act Func <Task> action = () => sut.Delete <FakeUser>(sourceId, default); // Assert action.ShouldNotThrow(); }