Example #1
0
 private void CheckFailResponse(BaseCommandBotResponse <ICommandResponseBody> botResponse)
 {
     Assert.IsNull(botResponse);
     //Assert.IsNotNull(botResponse);
     //Assert.AreEqual(CommandBotResponseType.StateCommand, botResponse.respType);
     //Assert.IsNotNull(botResponse.response);
     //var botResponseBody = botResponse.response as BotCommandStateResponse;
     //Assert.IsNotNull(botResponseBody);
     //Assert.AreEqual(BotCommandStateType.Error, botResponseBody.state);
 }
        public async Task BaseRPDesOk()
        {
            var serilaizedObject = JsonConvert.SerializeObject(
                new BaseCommandBotRequest <MessageCommandBotRequest>("123", "asdasd", new MessageCommandBotRequest("mes"),
                                                                     "ru-RU", Token, BotCommandContext.MessagingPostForm));
            var trueResultStr = await _proc.ProcessAsync(serilaizedObject);

            Assert.IsNotNull(trueResultStr);
            BaseCommandBotResponse <BotCommandStateResponse> trueResult = null;

            try
            {
                trueResult = JsonConvert.DeserializeObject <BaseCommandBotResponse <BotCommandStateResponse> >(trueResultStr);
                Assert.IsNotNull(trueResult);
            }
            catch (Exception e)
            {
                Assert.Fail("Can not deserialize trueResult response string");
            }
            Assert.IsNotNull(trueResult.response);
            Assert.AreEqual(Token, trueResult.token);
            Assert.AreEqual(CommandBotResponseType.Post, trueResult.respType);
        }
Example #3
0
 protected BaseCommandBotResponse <ICommandResponseBody> CastResponse <TResponseBody>(BaseCommandBotResponse <TResponseBody> response, string token) where TResponseBody : ICommandResponseBody
 {
     return(response == null ? null : new BaseCommandBotResponse <ICommandResponseBody>(response.respType, response.response, token));
 }