Ejemplo n.º 1
0
        public async Task SaveChanges_ShouldSupportSoftDelete()
        {
            // Arrange
            var entity = new CustomSoftDeleteEntity();
            var sut    = new CustomAppDbContext(_options, _currentUser.Object, _datetime.Object, _mediator.Object);

            // Act
            await sut.AddAsync(entity);

            await sut.SaveChangesAsync();

            sut.Remove(entity);

            await sut.SaveChangesAsync();

            // Assert
            entity.IsDeleted.Should().BeTrue();
        }
Ejemplo n.º 2
0
        public async Task SaveChanges_ShouldRaiseEvent()
        {
            // Arrange
            INotification eve = new CustomEvent();

            User user = GetDefaultUser();

            user.Events.Add(eve);

            var sut = new CustomAppDbContext(_options, _currentUser.Object, _datetime.Object, _mediator.Object);

            // Act
            await sut.AddAsync(user);

            await sut.SaveChangesAsync();

            // Assert
            _mediator.Verify(x => x.Publish(eve, It.IsAny <CancellationToken>()), Times.Once);
        }