コード例 #1
0
ファイル: FBPostTest.cs プロジェクト: HansinieJ/seshell
        public void TweetPostSuccessfull(FBPostData  TData)
        {
            string currentExecutingMethod = Utilities.GetCurrentMethod();
            var resultsWriter = new ResultsWriter(Constants.ParameterizedTest, currentExecutingMethod, true);
            var TweetTestData = FBPostData.GetTweetTestCases();

            Parallel.ForEach(WebDrivers, (driver, loopState) =>
            {
                var testAsserter = new TestCaseAsserts();
                string currentWebBrowserString = Utilities.GetWebBrowser(driver);

                if (TweetTestData != null)
                {
                    ResultReport testResultReport = new ResultReport();
                    string testFixtureName = Utilities.GenerateTestFixtureName(this.GetType(), currentExecutingMethod,
                    currentWebBrowserString);
                    testResultReport.StartMethodTimerAndInitiateCurrentTestCase(testFixtureName, true);
                    try
                    {

                        FBLoginPageFlow loginPageflow = new FBLoginPageFlow(driver);
                        FBProfilePageFlow profilePageFlow = loginPageflow.LogIn(TData.UserName, TData.Password);

                        //TwitterProfilePageFlow profilePageflow = new TwitterProfilePageFlow(driver);
                        profilePageFlow.Post(TData.Message);

                        testAsserter.AddBooleanAssert(
                         new Action<bool, string>(Assert.IsTrue),
                            profilePageFlow.VerifyPost(TData.Message),

                            Utilities.CombineTestOutcomeString(Constants.SuccessfulLegalEntityCreation, TData.Message));

                        testResultReport.SetCurrentTestCaseOutcome(true, testAsserter.AssertionCount.ToString());
                    }
                    catch (Exception e)
                    {
                        string screenShotIdentifier = String.Format("{0} - {1}", TData.Message, currentExecutingMethod);
                        //string screenShotIdentifier = String.Format("{0} - {1}", posts.PostedTweet, currentExecutingMethod);
                        base.HandleException(e, screenShotIdentifier, driver, testResultReport, testAsserter, resultsWriter);
                        Assert.Fail("***** TwitterLoginSuccessful Failed *****");
                    }
                    finally
                    {
                        testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                        base.TestCases.Add(testResultReport.currentTestCase);
                    }
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }
コード例 #2
0
ファイル: LoginTest.cs プロジェクト: harindu61/twitterTest
        public void LoginTwitter(LoginData data)
        {
            string currentExecutingMethod = Utilities.GetCurrentMethod();
            var resultsWriter = new ResultsWriter(Constants.ParameterizedTest, currentExecutingMethod, true);
            //var loginTestData = FBLoginData.GetLoginTestCases();

            Parallel.ForEach(WebDrivers, (driver, loopState) =>
            {
                var testAsserter = new TestCaseAsserts();
                string currentWebBrowserString = Utilities.GetWebBrowser(driver);
                //FBLoginData data = Utilities.GetBrowserBasedLoginCredentials(driver);

                ResultReport testResultReport = new ResultReport();
                string testFixtureName = Utilities.GenerateTestFixtureName(this.GetType(), currentExecutingMethod,
                currentWebBrowserString);
                testResultReport.StartMethodTimerAndInitiateCurrentTestCase(testFixtureName, true);
                try
                {
                    LoginPageFlow loginPageflow = new LoginPageFlow(driver);
                    HomePageFlow homePageFlow = loginPageflow.login(data.username, data.password);

                    testAsserter.AddBooleanAssert(
                        new Action<bool, string>(Assert.IsTrue),
                        homePageFlow.userLoggedIn(data.expectedResult),
                        Utilities.CombineTestOutcomeString(Constants.SuccessfulUserLogin, data.expectedResult));
                    testResultReport.SetCurrentTestCaseOutcome(true, testAsserter.AssertionCount.ToString());
                }
                catch (Exception e)
                {
                    string screenShotIdentifier = String.Format("{0} - {1}", data.username, currentExecutingMethod);
                    base.HandleException(e, screenShotIdentifier, driver, testResultReport, testAsserter, resultsWriter);
                    Assert.Fail("***** LoginTwitter Failed *****");
                }
                finally
                {
                    testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                    base.TestCases.Add(testResultReport.currentTestCase);
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }
コード例 #3
0
ファイル: AbstractTest.cs プロジェクト: harindu61/twitterTest
 protected void HandleException(
     Exception ex,
     string screenshotIdentifier, 
     IWebDriver webDriver,
     ResultReport resultReport, 
     TestCaseAsserts asserts, 
     ResultsWriter writer)
 {
     ScreenShotImage.CaptureScreenShot(
                     webDriver,
                     Utilities.CombineTestOutcomeString(Constants.ScreenshotError, screenshotIdentifier));
     resultReport.SetCurrentTestCaseOutcome(
         false,
         asserts.AssertionCount.ToString(),
         ex.Message,
         ex.StackTrace);
     resultReport.StopMethodTimerAndFinishCurrentTestCase();
     this.TestCases.Add(resultReport.currentTestCase);
     writer.WriteResultsToFile(this.GetType().Name, TestCases);
 }