public void UpdateScriptTest_Success() { var scriptResource = new ScriptResource(); var script = new Script { Version = "1" }; _mapper.Setup(m => m.Map <ScriptResource, Script>(scriptResource, script)) .Returns(script); _mapper.Setup(m => m.Map <Script, ScriptResource>(script)) .Returns(scriptResource); _scriptRepository.Setup(sr => sr.GetScriptWithTagsAsync(1)) .Returns(Task.FromResult(script)); _unitOfWork.Setup(uow => uow.CompleteAsync()) .Returns(Task.FromResult(1)); var updateScriptCommand = new UpdateScriptCommand.Handler( _dateTime.Object, _scriptRepository.Object, _unitOfWork.Object); var result = updateScriptCommand.Handle( new UpdateScriptCommand { Id = 1, Name = "name", Tags = new List <TagResource>() }, CancellationToken.None).Result; _scriptRepository.Verify(sr => sr.GetScriptWithTagsAsync(1)); _unitOfWork.Verify(uow => uow.CompleteAsync()); }
public void UpdateScriptTest_NoneScript_Success() { var scriptResource = new ScriptResource(); _scriptRepository.Setup(sr => sr.GetScriptWithTagsAsync(1)) .Returns(Task.FromResult(default(Script))); var updateScriptCommand = new UpdateScriptCommand.Handler( _dateTime.Object, _scriptRepository.Object, _unitOfWork.Object); Assert.ThrowsAsync <NotFoundException>(() => updateScriptCommand.Handle( new UpdateScriptCommand { Id = 1, Name = "name", Tags = new List <TagResource>() }, CancellationToken.None)); }