public void Handle_NullProduct_ThrowError() { var command = new UpdateIntervalPropertiesCommand() { Product = null }; Assert.ThrowsExceptionAsync <ArgumentNullException>(() => _handler.Handle(command, default)); }
public async Task Handle_ValidArgument_UpdateClearCachAndPublishEvent() { var command = new UpdateIntervalPropertiesCommand() { Product = new Product() }; var collectionMock = new Mock <IMongoCollection <Product> >(); _repositoryMock.Setup(c => c.Collection).Returns(collectionMock.Object); await _handler.Handle(command, default); collectionMock.Verify(c => c.UpdateOneAsync(It.IsAny <FilterDefinition <Product> >(), It.IsAny <UpdateDefinition <Product> >(), null, default), Times.Once); _cacheMock.Verify(c => c.RemoveByPrefix(It.IsAny <string>(), It.IsAny <bool>()), Times.Once); _mediatorMock.Verify(c => c.Publish(It.IsAny <EntityUpdated <Product> >(), default(CancellationToken)), Times.Once); }