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 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 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); }