コード例 #1
0
        public TwitterController()
        {
            twitterAccessService = new TwitterAccessService();
            calculateTweetAggregates = new CalculateTweetAggregatesService();
            loadAccountDetailsService = new LoadAccountDetailsService(twitterAccessService, calculateTweetAggregates);

            accountManager = new AccountManagerService(loadAccountDetailsService);
        }
        public void WhenPopulatedAccountIsCalledAndAnAccountIsProvidedTheAccountIsPopulated()
        {
            //Arrange
            var twitterAccessService = new TwitterAccessService();
            var calculateTweetAggregates = new CalculateTweetAggregatesService();
            var loadAccountDetailsService = new LoadAccountDetailsService(twitterAccessService, calculateTweetAggregates);
            var account = new Account("PayByPhone");

            //Act
            loadAccountDetailsService.PopulatedAccount(account, 1);

            //Assert
            Assert.NotNull(account.Name);
            Assert.NotNull(account.Tweets);
        }
        public void WhenGetAccountIsCalledTheAccountsAreReturned()
        {
            //Arrange
            var twitterAccessService = new TwitterAccessService();
            var calculateTweetAggregates = new CalculateTweetAggregatesService();
            var loadAccountDetailsService = new LoadAccountDetailsService(twitterAccessService, calculateTweetAggregates);
            var accountManager = new AccountManagerService(loadAccountDetailsService);
            var expected = 1;

            //Act
            accountManager.CreateAccount("PayByPhone_UK", 3);
            var accounts = accountManager.GetAccounts();

            //Assert
            Assert.Equal(expected, accounts.Count);
        }
        public void WhenCreateTweetResultisCalledandAnAccountIsProvideATweetResultIsReturned()
        {
            //Arrange
            var twitterAccessService = new TwitterAccessService();
            var calculateTweetAggregates = new CalculateTweetAggregatesService();
            var loadAccountDetailsService = new LoadAccountDetailsService(twitterAccessService, calculateTweetAggregates);
            var accountManager = new AccountManagerService(loadAccountDetailsService);
            accountManager.CreateAccount("PayByPhone_UK", 14);
            var accounts = accountManager.GetAccounts();

            //Act
            var twitterResultService = new FormatTweetResultService();
            var tweetResult = twitterResultService.CreateTweetResult(accounts);

            //Assert
            Assert.NotNull(tweetResult);
        }
        public void WhenCreateEmptyAccountIsCalledAPopulatedAccountIsCreated()
        {
            //Arrange
            var twitterAccessService = new TwitterAccessService();
            var calculateTweetAggregates = new CalculateTweetAggregatesService();
            var loadAccountDetailsService = new LoadAccountDetailsService(twitterAccessService, calculateTweetAggregates);
            var accountManager = new AccountManagerService(loadAccountDetailsService);

            //Act
            accountManager.CreateAccount("PayByPhone_UK", 14);

            //Assert
            var accounts = accountManager.GetAccounts();
            foreach (var account in accounts)
            {
                Assert.NotNull(account.Name);
                Assert.True(account.Tweets.Count > 1);
                Assert.True(account.TotalTweets > 1);
            }
        }