public void GetDeltaRequest_Should_Be_Invalid_Multihash()
        {
            //Arrange
            var hash           = "test";
            var commandContext = TestCommandHelpers.GenerateCliRequestCommandContext();
            var command        = new GetDeltaCommand(commandContext, _logger);

            //Act
            TestCommandHelpers.GenerateRequest(commandContext, command, "-n", "node1", "-h", hash);

            //Assert
            commandContext.UserOutput.Received(1).WriteLine($"Unable to parse hash {hash} as a Cid");
        }
        public void GetDeltaResponse_Error_On_Null_Delta()
        {
            //Arrange
            var deltaResponse   = new GetDeltaResponse();
            var commandContext  = TestCommandHelpers.GenerateCliResponseCommandContext(_testScheduler);
            var getDeltaCommand = new GetDeltaCommand(commandContext, _logger);

            //Act
            TestCommandHelpers.GenerateResponse(commandContext, deltaResponse);

            _testScheduler.Start();

            //Assert
            commandContext.UserOutput.Received(1).WriteLine(GetDeltaCommand.UnableToRetrieveDeltaMessage);
        }
        public void GetDeltaResponse_Can_Get_Output()
        {
            //Arrange
            var deltaResponse = new GetDeltaResponse {
                Delta = new Delta()
            };
            var commandContext  = TestCommandHelpers.GenerateCliResponseCommandContext(_testScheduler);
            var getDeltaCommand = new GetDeltaCommand(commandContext, _logger);

            //Act
            TestCommandHelpers.GenerateResponse(commandContext, deltaResponse);

            _testScheduler.Start();

            //Assert
            commandContext.UserOutput.Received(1).WriteLine(deltaResponse.Delta.ToJsonString());
        }
        public void GetDeltaRequest_Can_Be_Sent()
        {
            //Arrange
            var hashProvider   = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
            var deltaMultiHash = CidHelper.CreateCid(hashProvider.ComputeUtf8MultiHash("previous"));
            var commandContext = TestCommandHelpers.GenerateCliRequestCommandContext();
            var connectedNode  = commandContext.GetConnectedNode(null);
            var command        = new GetDeltaCommand(commandContext, _logger);

            //Act
            TestCommandHelpers.GenerateRequest(commandContext, command, "-n", "node1", "-h", deltaMultiHash);

            //Assert
            var requestSent = TestCommandHelpers.GetRequest <GetDeltaRequest>(connectedNode);

            requestSent.Should().BeOfType(typeof(GetDeltaRequest));
        }