private async void Post_Button_Click(object sender, RoutedEventArgs e)
        {
            ButtonStates(false);

            if (VerifyData() && VerifySelection())
            {
                PostingCommand posting = GetData();

                if (Auto_CheckBox.IsChecked == true)
                {
                    AccountTableModel account = GetRandomAccount();
                    posting.Emails.Add(account.Email);
                    posting.Passwords.Add(account.Password);
                }
                else
                {
                    (List <string> emails, List <string> passwords) = GetAccounts();
                    posting.Emails    = emails;
                    posting.Passwords = passwords;
                }

                using (IFBAccess fBAccess = new FBAccess(new BrowserInteractor()))
                {
                    await new PostingCommandHandler(fBAccess).Handle(posting);
                }

                MessageBox.Show("Posting Completed!", "Success", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show("Provided Data is Invalid", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            ButtonStates(true);
        }
示例#2
0
 public async Task PostToGroups([FromBody] PostingCommand command)
 {
     using (fBAccess)
     {
         await new PostingCommandHandler(fBAccess).Handle(command);
     }
 }
        public void Matches_NullCommand_Returns_False()
        {
            var  mockRepository = new Mock <IUserRepository>();
            var  postingCommand = new PostingCommand(mockRepository.Object);
            bool result         = postingCommand.Matches(null);

            Assert.IsFalse(result);
        }
        public void Matches_PostCommand_Return_True()
        {
            var  mockRepository = new Mock <IUserRepository>();
            var  postingCommand = new PostingCommand(mockRepository.Object);
            bool result         = postingCommand.Matches(CommandLine);

            Assert.IsTrue(result);
        }
        public void ExecutePostCommand_When_User_Exists_Returns_True()
        {
            //arrange
            var mockRepository = new Mock <IUserRepository>();
            var user           = new User(Username);

            mockRepository.Setup(m => m.GetUser(It.IsAny <string>())).Returns(() => user);
            var postingCommand = new PostingCommand(mockRepository.Object);

            //act
            postingCommand.ExecuteCommand(CommandLine);
            var postAdded = user.Posts.Select(m => m.Message).FirstOrDefault();

            //assert
            mockRepository.Verify(m => m.GetUser(It.IsAny <string>()), Times.Once);
            Assert.AreEqual(Message, postAdded);
        }