public void Should_Be_Invalid_Command() { var _invalidCommand = new DownloadVideoCommand(new Guid(), new Guid()); _invalidCommand.Validate(); Assert.True(_invalidCommand.IsInvalid); }
public void Should_Be_Valid_Command() { var _validCommand = new DownloadVideoCommand(Guid.NewGuid(), Guid.NewGuid()); _validCommand.Validate(); Assert.True(!_validCommand.IsInvalid); }
public ICommandResult Handle(DownloadVideoCommand command) { command.Validate(); if (command.IsInvalid) { return(new FileCommandResult(CommandResultStatus.InvalidCommand, command.Notifications)); } try { var video = _videoRepository.GetByServerIdAndVideoId(command.ServerId, command.VideoId); if (video == null) { return(new FileCommandResult(CommandResultStatus.InvalidData, "Video não foi localizado")); } var videoStream = _videoRepository.GetInFileSystem(video); return(new FileCommandResult(video, videoStream)); } catch (Exception e) { Console.WriteLine($"Fail to execute DownloadVideoHandler. Fail stack ===> {e.ToString()}"); return(new FileCommandResult(CommandResultStatus.Exception)); } }
public DownloadVideoHandlerTest() { _fakeServerRepository = new FakeServerRepository(_dataContextMock); _fakeVideoRepository = new FakeVideoRepository(_dataContextMock); _invalidCommand = new DownloadVideoCommand(new Guid(), new Guid()); _validCommandWithNotExistsId = new DownloadVideoCommand(Guid.NewGuid(), Guid.NewGuid()); var videoValid = _dataContextMock.Videos.FirstOrDefault(); _validCommand = new DownloadVideoCommand(videoValid.ServerId, videoValid.Id); }