コード例 #1
0
ファイル: PopRequest.cs プロジェクト: ivryakhov/mental_stack
        public string ProcessRequest(MStackService mStackService)
        {
            var resType = (mStackService.Pop(_user, out string message));

            if (resType == MStackService.ResultType.PopSuccess)
            {
                return(message);
            }
            else
            {
                return(_resultMessages[resType]);
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }