Esempio n. 1
0
 public static void RegisterPages()
 {
     Console.WriteLine("Execute BeforeTestRun- RegisterPages");
     Driver.StartBrowser(BrowserTypes.Chrome);
     UnityContainerFactory.GetContainer().RegisterType <HomePage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <KilowattHoursPage>(new ContainerControlledLifetimeManager());
 }
Esempio n. 2
0
 public BaseTest()
 {
     this.container = UnityContainerFactory.GetContainer();
     this.container.RegisterInstance <IUnityContainer>(this.container);
     this.currentTestExecutionProvider = new TestExecutionProvider();
     this.InitializeTestExecutionBehaviorObservers(this.currentTestExecutionProvider);
 }
Esempio n. 3
0
 public ConvertMetricsForNuclearScienceSteps()
 {
     this.homePage =
         UnityContainerFactory.GetContainer().Resolve <HomePage>();
     this.kilowattHoursPage =
         UnityContainerFactory.GetContainer().Resolve <KilowattHoursPage>();
 }
        public static void Register(HttpConfiguration config)
        {
            //注册异常过滤器特性(全部webapi)
            config.Filters.Add(new CustomExceptionAttribute());
            //注册全局异常处理;不会覆盖异常过滤器特性
            config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());

            ////注册操作方法过滤器特性(一般不全局设置)
            //config.Filters.Add(new CustomActionAttribute());

            //注册容器
            config.DependencyResolver = new UnityDependencyResolver(UnityContainerFactory.GetContainer());


            //string origins = ConfigurationManager.AppSettings["cors:allowedOrigins"];
            //string headers = ConfigurationManager.AppSettings["cors:allowedHeaders"];
            //string methods = ConfigurationManager.AppSettings["cors:allowedMethods"];
            //config.EnableCors(new EnableCorsAttribute(origins, headers, methods));

            //config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

            config.EnableCors();

            // Web API 配置和服务

            // Web API 路由
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Esempio n. 5
0
 public SignInPageLoginBehaviour()
 {
     this.signInPage =
         UnityContainerFactory.GetContainer().Resolve <SignInPage>();
     this.shippingAddressPage =
         UnityContainerFactory.GetContainer().Resolve <ShippingAddressPage>();
 }
Esempio n. 6
0
 public BaseTest()
 {
     Container = UnityContainerFactory.GetContainer();
     Container.RegisterInstance(Container);
     _currentTestExecutionProvider = new TestExecutionProvider();
     InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider, Container);
 }
 public ShippingAddressPageFillShippingBehaviour(
     ClientPurchaseInfo clientPurchaseInfo)
 {
     _shippingAddressPage =
         UnityContainerFactory.GetContainer().Resolve <ShippingAddressPage>();
     _clientPurchaseInfo = clientPurchaseInfo;
 }
Esempio n. 8
0
 public static void RegisterPages()
 {
     Driver.StartBrowser(BrowserTypes.Chrome);
     UnityContainerFactory.GetContainer().RegisterType <HomePage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <KilowattHoursPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser);
 }
Esempio n. 9
0
 private static void RegisterServices()
 {
     _emailService          = UnityContainerFactory.GetContainer().Resolve <IEmailService>();
     _sportsService         = UnityContainerFactory.GetContainer().Resolve <ISportsService>();
     _transportationService = UnityContainerFactory.GetContainer().Resolve <ITransportationService>();
     _weatherService        = UnityContainerFactory.GetContainer().Resolve <IWeatherService>();
 }
Esempio n. 10
0
        public void SetupTest()
        {
            UnityContainerFactory.GetContainer().RegisterType <IDriver, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <INavigationService, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <IBrowser, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <ICookieService, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <IDialogService, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <IElementFinder, TestingFrameworkDriver>();
            UnityContainerFactory.GetContainer().RegisterType <IJavaScriptInvoker, TestingFrameworkDriver>();

            UnityContainerFactory.GetContainer().RegisterType <IInputSubmit, InputSubmit>();
            UnityContainerFactory.GetContainer().RegisterType <ISearch, Search>();
            UnityContainerFactory.GetContainer().RegisterType <IDiv, Div>();
            UnityContainerFactory.GetContainer().RegisterType <BingMainPage>();

            UnityContainerFactory.GetContainer().RegisterInstance(UnityContainerFactory.GetContainer());
            UnityContainerFactory.GetContainer().RegisterInstance(BrowserSettings.DefaultChomeSettings);
            _driver = UnityContainerFactory.GetContainer().Resolve <IDriver>();

            UnityContainerFactory.GetContainer().RegisterInstance(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <IBrowser>(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <ICookieService>(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <IDialogService>(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <IJavaScriptInvoker>(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <INavigationService>(_driver);
            UnityContainerFactory.GetContainer().RegisterInstance <IElementFinder>(_driver);

            // Register the concrete Unit Testing Framework.
            UnityContainerFactory.GetContainer().RegisterType <IAssert, MsTestAssert>();
        }
Esempio n. 11
0
        public void AssertOrderTotalPrice(string itemPrice)
        {
            var placeOrderPage = UnityContainerFactory.GetContainer().Resolve <PlaceOrderPage>();
            var totalPrice     = double.Parse(itemPrice);

            placeOrderPage.AssertOrderTotalPrice(totalPrice);
        }
        public static void AssemblyInit(TestContext context)
        {
            var container = UnityContainerFactory.GetContainer();

            UnityContainerFactory.GetContainer().RegisterType <ITestBehaviorObserver, ExecutionEngineBehaviorObserver>(Guid.NewGuid().ToString());
            UnityContainerFactory.GetContainer().RegisterType <ITestExecutionEngine, TestExecutionEngine>(Guid.NewGuid().ToString());
            UnityContainerFactory.GetContainer().RegisterInstance(container);
        }
 public static void AnalyzeFor <TExceptionHander>(Action action)
     where TExceptionHander : Handler, new()
 {
     using (UnityContainerFactory.GetContainer().Resolve <TestsExceptionsAnalyzerContext <TExceptionHander> >())
     {
         action();
     }
 }
Esempio n. 14
0
        public void SearchForAutomateThePlanet()
        {
            var bingMainPage = UnityContainerFactory.GetContainer().Resolve <BingMainPage>();

            bingMainPage.Navigate();
            bingMainPage.Search("Automate The Planet");
            bingMainPage.AssertResultsCountIsAsExpected("422,000 results");
        }
 public void ClassInit()
 {
     UnityContainerFactory.GetContainer().RegisterType <HomePage>();
     UnityContainerFactory.GetContainer().RegisterType <ArticlePage>();
     UnityContainerFactory.GetContainer().RegisterType <CategoryPage>();
     _driver = new ChromeDriver();
     UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(_driver);
 }
Esempio n. 16
0
 private void MakeSuccessorMainHandler()
 {
     for (var i = 0; i < GetType().GetGenericArguments().Length; i++)
     {
         var handler = ScopeStack.Pop();
         UnityContainerFactory.GetContainer().RegisterInstance(ExceptionAnalyzerConstants.MainApplicationHandlerName, handler.Successor);
         handler.ClearSuccessor();
     }
 }
        private void InitializeTestExecutionBehaviorObservers(TestExecutionProvider testExecutionProvider)
        {
            var observers = UnityContainerFactory.GetContainer().ResolveAll <ITestBehaviorObserver>();

            foreach (var observer in observers)
            {
                observer.Subscribe(testExecutionProvider);
            }
        }
Esempio n. 18
0
        public static void BeforeTestRun()
        {
            SetUp();

            //register pages
            UnityContainerFactory.GetContainer().RegisterType <CommonPage>(new ContainerControlledLifetimeManager());

            Log.Information("******************************************");
            Log.Information("\nNew Test Cycle :");
        }
Esempio n. 19
0
        protected void AddHandlerInfrontOfChain <TNewHandler>()
            where TNewHandler : Handler, new()
        {
            var mainApplicationHandler = UnityContainerFactory.GetContainer().Resolve <Handler>(ExceptionAnalyzerConstants.MainApplicationHandlerName);
            var newHandler             = UnityContainerFactory.GetContainer().Resolve <TNewHandler>();

            newHandler.SetSuccessor(mainApplicationHandler);
            UnityContainerFactory.GetContainer().RegisterInstance <Handler>(ExceptionAnalyzerConstants.MainApplicationHandlerName, newHandler);
            ScopeStack.Push(newHandler);
        }
        public void NavigateToItemUrl(Table productsTable)
        {
            var itemPage = UnityContainerFactory.GetContainer().Resolve <ItemPage>();
            var products = productsTable.CreateDynamicSet();

            foreach (var product in products)
            {
                itemPage.Navigate(string.Concat(product.Url, "?", product.AffilicateCode));
                itemPage.ClickBuyNowButton();
            }
        }
Esempio n. 21
0
        public static void BeforeTestRun()
        {
            SetUp();

            //Registering pages
            UnityContainerFactory.GetContainer().RegisterType <LandingPage>(new ContainerControlledLifetimeManager());
            UnityContainerFactory.GetContainer().RegisterType <SignInPage>(new ContainerControlledLifetimeManager());

            Log.Information("");
            Log.Information("\nNew Test Cycle :");
        }
        public static void AssemblyInit(TestContext context)
        {
            var container = UnityContainerFactory.GetContainer();

            UnityContainerFactory.GetContainer().RegisterType <ITestBehaviorObserver, ExecutionEngineBehaviorObserver>(Guid.NewGuid().ToString());
            UnityContainerFactory.GetContainer().RegisterType <ITestExecutionEngine, TestExecutionEngine>(Guid.NewGuid().ToString());
            UnityContainerFactory.GetContainer().RegisterInstance(container);

            // Unsubscribe execution engine observer and start single instance of the browser for the whole execution.
            ////testingFrameworkTestExecutionEngine = new TestExecutionEngine(container);
            ////testingFrameworkTestExecutionEngine.RegisterDependencies(Browsers.Chrome);
        }
Esempio n. 23
0
        public static void BeforeTestRun()
        {
            //Initialize Log File
            Driver.CreateLog();

            //Initialize Reports
            reportInitalise();

            UnityContainerFactory.GetContainer().RegisterType <CommonPage>(new ContainerControlledLifetimeManager());
            Driver.CreateLog("Logs");

            Log.Information("******************************************");
            Log.Information("\nNew Test Cycle :");
        }
 public static void Execute(params BehaviorDefinition[] behaviorDefinitions)
 {
     foreach (var definition in behaviorDefinitions)
     {
         var behavior =
             UnityContainerFactory.GetContainer().Resolve(
                 definition.BehaviorType,
                 new ResolverOverride[]
         {
             new ParameterOverride("definition", definition)
         }) as Behavior;
         behavior.Execute();
     }
 }
Esempio n. 25
0
        public void FillShippingInfo(string fullName, string country, string address, string state, string city, string zip, string phone)
        {
            var shippingAddressPage = UnityContainerFactory.GetContainer().Resolve <ShippingAddressPage>();
            var clientPurchaseInfo  = new ClientPurchaseInfo(
                new ClientAddressInfo()
            {
                FullName = fullName,
                Country  = country,
                Address1 = address,
                State    = state,
                City     = city,
                Zip      = zip,
                Phone    = phone
            });

            shippingAddressPage.FillShippingInfo(clientPurchaseInfo);
        }
Esempio n. 26
0
        public static void Register(HttpConfiguration config)
        {
            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

            config.Filters.Add(new CustomActionFilterAttribute());
            //config.Services.Replace(typeof(IExceptionHandler),new Glo)
            // Web API configuration and services
            //replace Container of Unity
            config.DependencyResolver = new UnityDependencyResolver(UnityContainerFactory.GetContainer());
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Esempio n. 27
0
        public static void setUpBrowser()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("AppConfig.json")
                         .Build();

            string browserName = config["Browser"];

            if (browserName.Equals("Chrome"))
            {
                Driver.StartBrowser(BrowserTypes.Chrome, 30, GetChromeOptions());
            }
            else if (browserName.Equals("ChromeHeadless"))
            {
                Driver.StartBrowser(BrowserTypes.ChromeHeadless, 30, GetChromeOptions());
            }
            else if (browserName.Equals("Edge"))
            {
                Driver.StartBrowser(BrowserTypes.Edge, 30);
            }
            else if (browserName.Equals("Firefox"))
            {
                Driver.StartBrowser(BrowserTypes.Firefox, 30);
            }
            else if (browserName.Equals("FirefoxHeadless"))
            {
                Driver.StartBrowser(BrowserTypes.FirefoxHeadless, 30);
            }
            else if (browserName.Equals("InternetExplorer"))
            {
                Driver.StartBrowser(BrowserTypes.InternetExplorer, 30, GetIEOptions());
            }
            else if (browserName.Equals("Opera"))
            {
                Driver.StartBrowser(BrowserTypes.Opera, 30);
            }
            else if (browserName.Equals("Safari"))
            {
                Driver.StartBrowser(BrowserTypes.Safari, 30);
            }

            //Registering BrowserDriver
            UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser);
        }
Esempio n. 28
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // initialize IoC container so it runs prior to navigation
                UnityContainerFactory.GetContainer();

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
 public static void BeforeTestRun()
 {
     Driver.StartBrowser(BrowserTypes.Chrome);
     UnityContainerFactory.GetContainer().RegisterType <ItemPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <PreviewShoppingCartPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <SignInPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingAddressPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingPaymentPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <PlaceOrderPage>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ItemPageBuyBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ItemPageNavigationBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <PlaceOrderPageAssertFinalAmountsBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <PreviewShoppingCartPageProceedBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingAddressPageContinueBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingAddressPageFillDifferentBillingBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingAddressPageFillShippingBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <ShippingPaymentPageContinueBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterType <SignInPageLoginBehaviour>(new ContainerControlledLifetimeManager());
     UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser);
 }
Esempio n. 30
0
        public void FillDifferentBillingInfo(string fullName, string country, string address, string state, string city, string zip, string phone)
        {
            var shippingAddressPage = UnityContainerFactory.GetContainer().Resolve <ShippingAddressPage>();
            var shippingPaymentPage = UnityContainerFactory.GetContainer().Resolve <ShippingPaymentPage>();
            var clientPurchaseInfo  = new ClientPurchaseInfo(
                new ClientAddressInfo()
            {
                FullName = fullName,
                Country  = country,
                Address1 = address,
                State    = state,
                City     = city,
                Zip      = zip,
                Phone    = phone
            });

            shippingAddressPage.ClickDifferentBillingCheckBox(clientPurchaseInfo);
            shippingAddressPage.ClickContinueButton();
            shippingPaymentPage.ClickBottomContinueButton();
            shippingAddressPage.FillBillingInfo(clientPurchaseInfo);
        }