Esempio n. 1
0
        public string ProcessRequest(MStackService mStackService)
        {
            var resType = (mStackService.Pop(_user, out string message));

            if (resType == MStackService.ResultType.PopSuccess)
            {
                return(message);
            }
            else
            {
                return(_resultMessages[resType]);
            }
        }
Esempio n. 2
0
        public void Push_UserDoesNotExistBefore_CreatesNewMStackInDb()
        {
            var    mStackService = new MStackService(_memoryCacheMock.Object);
            var    result        = mStackService.Push(_user, _message);
            object expectedValue = null;

            _memoryCacheMock
            .Setup(m => m.TryGetValue(It.IsAny <string>(), out expectedValue))
            .Returns(false);

            Assert.Equal(MStackService.ResultType.UserAdded, result);
            _memoryCacheMock.Verify(x => x.CreateEntry(_user));
        }
Esempio n. 3
0
        public void Pop_UserDoesNotExist_ReturnNoStackResult()
        {
            object expectedValue = null;

            _memoryCacheMock
            .Setup(m => m.TryGetValue(It.IsAny <string>(), out expectedValue))
            .Returns(false);

            var mStackService = new MStackService(_memoryCacheMock.Object);
            var result        = mStackService.Pop(_user, out string expectedMessage);

            Assert.Equal(MStackService.ResultType.NoStack, result);
            Assert.Equal("", expectedMessage);
        }
Esempio n. 4
0
        public void Pop_UserExistsStackIsEmpty_ReturnEmptyStackResult()
        {
            var    messages      = new Stack <string>();
            object expectedValue = new MStack {
                User = _user, Messages = messages
            };

            _memoryCacheMock
            .Setup(m => m.TryGetValue(It.IsAny <string>(), out expectedValue))
            .Returns(true);

            var mStackService = new MStackService(_memoryCacheMock.Object);
            var result        = mStackService.Pop(_user, out string expectedMessage);

            Assert.Equal(MStackService.ResultType.EmptyStack, result);
            Assert.Null(expectedMessage);
        }
Esempio n. 5
0
        public GenResponse Process(MStackService mStackService)
        {
            var workRequest  = Request.CreateWorkRequest(Session.UserId);
            var responceText = workRequest.ProcessRequest(mStackService);

            return(new GenResponse()
            {
                Response = new Response()
                {
                    Text = responceText,
                    Tts = responceText,
                    EndSession = true
                },
                Session = Session,
                Version = Version
            });
        }
Esempio n. 6
0
        public void Pop_UserExistsStackNotEmpty_ReturnAppropriateMessage()
        {
            var messages = new Stack <string>();

            messages.Push(_message);
            object expectedValue = new MStack {
                User = _user, Messages = messages
            };

            _memoryCacheMock
            .Setup(m => m.TryGetValue(It.IsAny <string>(), out expectedValue))
            .Returns(true);

            var mStackService = new MStackService(_memoryCacheMock.Object);
            var result        = mStackService.Pop(_user, out string expectedMessage);

            Assert.Equal(MStackService.ResultType.PopSuccess, result);
            Assert.Equal(_message, expectedMessage);
        }
Esempio n. 7
0
        public void Push_UserAlreadyExists_UpdateMStackForTheUser()
        {
            var messages = new Stack <string>();

            messages.Push(_message);
            var mStack = new MStack {
                User = _user, Messages = messages
            };
            object expectedValue = mStack;

            _memoryCacheMock
            .Setup(m => m.TryGetValue(It.IsAny <string>(), out expectedValue))
            .Returns(true);

            var mStackService = new MStackService(_memoryCacheMock.Object);
            var result        = mStackService.Push(_user, _message);

            Assert.Equal(MStackService.ResultType.UserUpdated, result);
            _memoryCacheMock.Verify(x => x.CreateEntry(_user));
        }
Esempio n. 8
0
        public string ProcessRequest(MStackService mStackService)
        {
            var resType = (mStackService.Push(_user, CleanUtterance(_originalUtterance)));

            return(_resultMessages[resType]);
        }
Esempio n. 9
0
 public string ProcessRequest(MStackService mStackService)
 {
     return("Неизвестный запрос");
 }
Esempio n. 10
0
 public GenRequestController(MStackService mStackService, ILogger <GenRequestController> logger)
 {
     _mStackService = mStackService;
     _logger        = logger;
     _logger.LogInformation("GenRequestController started");
 }