Beispiel #1
0
        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder <MessageQueryGenerator>();
            _fakeMessageQueryValidator       = _fakeBuilder.GetFake <IMessageQueryValidator>();
            _fakeUserQueryParameterGenerator = _fakeBuilder.GetFake <IUserQueryParameterGenerator>();
            _fakeTwitterStringFormatter      = _fakeBuilder.GetFake <ITwitterStringFormatter>();

            _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();
        }
        public void GetFriendIdsQuery_WithValidUserScreenName_ReturnsExpectedQuery()
        {
            // Arrange
            var queryGenerator         = CreateUserQueryGenerator();
            var userScreenName         = TestHelper.GenerateString();
            var maximumNumberOfFriends = TestHelper.GenerateRandomInt();
            var userIdParameter        = UserQueryGeneratorHelper.GenerateParameterExpectedResult(userScreenName);

            _fakeUserQueryValidator.CallsTo(x => x.IsScreenNameValid(userScreenName)).Returns(true);
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();

            // Act
            var result = queryGenerator.GetFriendIdsQuery(userScreenName, maximumNumberOfFriends);

            // Assert
            var expectedResult = String.Format(Resources.User_GetFriends, userIdParameter, maximumNumberOfFriends);

            Assert.AreEqual(result, expectedResult);
        }
        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder <FriendshipQueryGenerator>();
            _fakeUserQueryParameterGenerator = _fakeBuilder.GetFake <IUserQueryParameterGenerator>();
            _fakeUserQueryValidator          = _fakeBuilder.GetFake <IUserQueryValidator>();

            _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateIdOrScreenNameParameter();
            _fakeUserQueryValidator.ArrangeIsUserIdValid();
        }
        public void VerifyGetPublishMessageQuery_WithTextAndMessageDTO(
            bool canMessageBePublished,
            bool isRecipientValid,
            bool isRecipientIdValid,
            bool isRecipientScreenNameValid,
            bool expectedValue)
        {
            var text        = TestHelper.GenerateString();
            var twitterText = TestHelper.GenerateString();

            _fakeTwitterStringFormatter.CallsTo(x => x.TwitterEncode(It.IsAny <string>())).Returns(twitterText);

            var messageDTO = A.Fake <IMessageDTO>();

            messageDTO.CallsTo(x => x.Text).Returns(text);

            _fakeMessageQueryValidator.CallsTo(x => x.IsMessageTextValid(text)).Returns(canMessageBePublished);
            _fakeMessageQueryValidator.CallsTo(x => x.CanMessageDTOBePublished(messageDTO)).Returns(canMessageBePublished);

            ArrangeMessageDTORecipient(messageDTO, isRecipientValid, isRecipientIdValid, isRecipientScreenNameValid);

            // Arrange
            var queryGenerator = CreateMessageQueryGenerator();
            var expectedIdentifierParameter = Guid.NewGuid().ToString();
            var expectedResult = String.Format(Resources.Message_NewMessage, twitterText, expectedIdentifierParameter);

            if (isRecipientValid)
            {
                _fakeUserQueryParameterGenerator.ArrangeGenerateIdOrScreenNameParameter(expectedIdentifierParameter);
            }
            else if (isRecipientIdValid)
            {
                _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter(expectedIdentifierParameter);
            }
            else
            {
                _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter(expectedIdentifierParameter);
            }

            // Act
            var result = queryGenerator.GetPublishMessageQuery(messageDTO);

            // Assert
            Assert.AreEqual(result, expectedValue ? expectedResult : null);
        }