public string ProcessRequest(MStackService mStackService) { var resType = (mStackService.Pop(_user, out string message)); if (resType == MStackService.ResultType.PopSuccess) { return(message); } else { return(_resultMessages[resType]); } }
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)); }
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); }
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); }
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 }); }
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); }
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)); }
public string ProcessRequest(MStackService mStackService) { var resType = (mStackService.Push(_user, CleanUtterance(_originalUtterance))); return(_resultMessages[resType]); }
public string ProcessRequest(MStackService mStackService) { return("Неизвестный запрос"); }
public GenRequestController(MStackService mStackService, ILogger <GenRequestController> logger) { _mStackService = mStackService; _logger = logger; _logger.LogInformation("GenRequestController started"); }