public void WhichShouldResolveCorrectControllerFilterLogicWithExplicitServices()
        {
            MyApplication
            .StartsFrom <DefaultStartup>()
            .WithServices(services => services
                          .AddTransient <IInjectedService, InjectedService>());

            MyPipeline
            .Configuration()
            .ShouldMap("/Pipeline/Action?controller=true")
            .To <PipelineController>(c => c.Action())
            .Which(controller => controller
                   .WithDependencies(new InjectedService()))
            .ShouldReturn()
            .Ok()
            .AndAlso()
            .ShouldPassForThe <PipelineController>(controller =>
            {
                const string testValue = "ControllerFilter";
                Assert.Equal(testValue, controller.Data);
                Assert.True(controller.RouteData.Values.ContainsKey(testValue));
                Assert.True(controller.ControllerContext.ActionDescriptor.Properties.ContainsKey(testValue));
                Assert.True(controller.ModelState.ContainsKey(testValue));
                Assert.NotNull(controller.HttpContext.Features.Get <PipelineController>());
            });

            MyApplication.StartsFrom <DefaultStartup>();
        }
        public void WhichShouldNotResolveControllerFilterLogicWithControllerConstructionFunction()
        {
            MyApplication
            .StartsFrom <DefaultStartup>()
            .WithServices(services => services
                          .AddTransient <IInjectedService, InjectedService>());

            var injectedService = new InjectedService();

            MyPipeline
            .Configuration()
            .ShouldMap("/Pipeline/Action?controller=true")
            .To <PipelineController>(c => c.Action())
            .Which(() => new PipelineController(injectedService))
            .ShouldReturn()
            .Ok()
            .AndAlso()
            .ShouldPassForThe <PipelineController>(controller =>
            {
                Assert.Same(injectedService, controller.Service);
                Assert.Null(controller.Data);
            });

            MyApplication.StartsFrom <DefaultStartup>();
        }
예제 #3
0
 public void GetAllValueForClientOne(IWebDriver driver)
 {
     freshStart     = new FreshStartHome(driver);
     commonhelper   = new WebObjectFunctions(driver);
     newEnroll      = new NewEnrollClient(driver);
     myPipeline     = new MyPipeline(driver);
     apiHelper      = new CommonAPIHelper(driver);
     pipelineSearch = new PipelineSearch(driver);
     //secondClientDetails = new Panorama_SecondClientDetails(driver);
     newEnroll.NavigateToFreshStartHome(driver, ConfigurationManager.AppSettings["FreshStartUrl"]);
     newEnroll.EnterLoanNumber(driver, ConfigurationManager.AppSettings["LoanNumber"]);
     newEnroll.NavigateToClientOption(driver);
     newEnroll.SelectFirstClient(driver);
     valueFirstName          = freshStart.FreshStartFirstName_TextBox.GetAttribute("value");
     valueLastName           = freshStart.FreshStartLastName_TextBox.GetAttribute("value");
     valueEmail              = freshStart.FreshStartEmail_TextBox.GetAttribute("value");
     valuePhone              = freshStart.FreshStartPhone_TextBox.GetAttribute("value");
     valueClientOneFirstName = freshStart.FreshStartClientInfoClientOneFirstName_TextBox.GetAttribute("value");
     valueClientOneLastName  = freshStart.FreshStartClientInfoClientOneLastName_TextBox.GetAttribute("value");
     valueClientOnePhone     = freshStart.FreshStartClientInfoClientOneHomePhone_TextBox.GetAttribute("value");
     valueClientOneEmail     = freshStart.FreshStartClientInfoClientOneEmail_TextBox.GetAttribute("value");
     valuePropertyAddress    = freshStart.FreshStartPropertyAddress_TextBox.GetAttribute("value");
     valuePropertyCity       = freshStart.FreshStartPropertyCity_TextBox.GetAttribute("value");
     substringValue          = valuePropertyAddress.Substring(0, 11);
 }
예제 #4
0
        public static void Init(TestContext context)
        {
            testContext    = context;
            driver         = Driver.Initialize(testContext.Properties["BrowserIEName"].ToString());
            freshStart     = new FreshStartHome(driver);
            commonhelper   = new WebObjectFunctions(driver);
            newEnroll      = new NewEnrollClient(driver);
            myPipeline     = new MyPipeline(driver);
            apiHelper      = new CommonAPIHelper(driver);
            pipelineSearch = new PipelineSearch(driver);
            string freshStartUrl = ConfigurationManager.AppSettings["FreshStartUrl"];

            newEnroll.NavigateToFreshStartHome(driver, freshStartUrl);
            Assert.IsTrue(commonhelper.ValidatateWebElementDisplayed(newEnroll.newEnroll_Subheading));
            Assert.IsTrue(commonhelper.ValidatateWebElementTextDisplayed(newEnroll.newEnroll_Subheading, ConfigurationManager.AppSettings["NewEnrollText"]));
            Assert.IsTrue(commonhelper.ValidatateWebElementDisplayed(newEnroll.newEnrollLoanNumber_Label));
            Assert.IsTrue(commonhelper.ValidatateWebElementTextDisplayed(newEnroll.newEnrollLoanNumber_Label, ConfigurationManager.AppSettings["LoanNumberText"]));
            Assert.IsTrue(commonhelper.ValidatateWebElementDisplayed(newEnroll.newEnrollLoanNumber_TextBox));
            Assert.IsTrue(commonhelper.ValidatateWebElementAttributeCheck(newEnroll.newEnrollLoanNumber_TextBox, ConfigurationManager.AppSettings["MaxLengthTenText"]));
            Assert.IsTrue(commonhelper.ValidatateWebElementAttributeCheck(newEnroll.newEnrollLoanNumber_TextBox, ConfigurationManager.AppSettings["NgPatternText"]));
            Assert.IsTrue(commonhelper.ValidatateWebElementAttributeCheck(newEnroll.newEnrollEntroll_Button, ConfigurationManager.AppSettings["DisabledText"]));
            newEnroll.EnterLoanNumber(driver, ConfigurationManager.AppSettings["LoanNumber"]);
            Assert.IsTrue(commonhelper.ValidatateWebRemovedElementAttributeCheck(newEnroll.newEnrollEntroll_Button, ConfigurationManager.AppSettings["DisabledText"]));
            newEnroll.NavigateToClientOption(driver);
            newEnroll.SelectFirstClient(driver);
        }
        public void WhichShouldOverrideActionFilterValuesInInnerBuilder()
        {
            MyApplication
            .StartsFrom <DefaultStartup>()
            .WithServices(services => services
                          .AddTransient <IInjectedService, InjectedService>());

            const string contextTestKey   = "ControllerFilter";
            const string contextTestValue = "Context Value";

            MyPipeline
            .Configuration()
            .ShouldMap("/Pipeline/Action?controller=true")
            .To <PipelineController>(c => c.Action())
            .Which(controller => controller
                   .WithRouteData(new { ControllerFilter = contextTestValue })
                   .WithControllerContext(context => context.ActionDescriptor.Properties[contextTestKey] = contextTestValue)
                   .WithActionContext(context => context.ModelState.Clear()))
            .ShouldReturn()
            .Ok()
            .AndAlso()
            .ShouldPassForThe <PipelineController>(controller =>
            {
                Assert.Equal(contextTestKey, controller.Data);
                Assert.True(controller.RouteData.Values.ContainsKey(contextTestKey));
                Assert.Equal(contextTestValue, controller.RouteData.Values[contextTestKey]);
                Assert.True(controller.ControllerContext.ActionDescriptor.Properties.ContainsKey(contextTestKey));
                Assert.Equal(contextTestValue, controller.ControllerContext.ActionDescriptor.Properties[contextTestKey]);
                Assert.Empty(controller.ModelState);
            });

            MyApplication.StartsFrom <DefaultStartup>();
        }
 public TcpChannelTest()
 {
     _pipeline = new MyPipeline();
     _sockets = SocketTestTools.CreateConnection();
     _target = new TcpServerClientChannel(_pipeline);
     _target.AssignSocket(_sockets.Client);
     _target.StartChannel();
 }
 public void ShouldMapShouldExecuteActionFiltersAndShouldValidateRoutes()
 {
     MyPipeline
     .Configuration()
     .ShouldMap(request => request
                .WithLocation("/Normal/FiltersAction")
                .WithAntiForgeryToken())
     .To <NormalController>(c => c.FiltersAction());
 }
 public void ShouldMapShouldExecuteAuthorizationFiltersAndShouldValidateJustRoutes()
 {
     MyPipeline
     .Configuration()
     .ShouldMap(request => request
                .WithLocation("/Normal/AuthorizedAction")
                .WithUser())
     .To <NormalController>(c => c.AuthorizedAction());
 }
 public void WhichShouldResolveCorrectEmptyAsyncAction()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("/Home/EmptyTask")
     .To <HomeController>(c => c.EmptyTask())
     .Which()
     .ShouldReturnEmpty();
 }
예제 #10
0
 public void PipelineAssertionShouldWorkCorrectlyWithVersioning()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("api/v2.0/versioning")
     .To <VersioningController>(c => c.Index())
     .Which()
     .ShouldReturn()
     .Ok();
 }
예제 #11
0
 public void RouteAssertionShouldWorkCorrectlyWithActionVersioningWhichDoesNotExist()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("api/v3.0/versioning")
     .To <VersioningController>(c => c.SpecificVersion())
     .Which()
     .ShouldReturn()
     .Ok();
 }
예제 #12
0
        public MyPipeline NavigateToMyPipelineHome(IWebDriver driver)
        {
            Actions action = new Actions(driver);

            action.MoveToElement(FreshStartMyPipeline_Button).Click().Perform();
            MyPipeline myPipeline = new MyPipeline(driver);

            action.MoveToElement(myPipeline.FreshStartGlobalSearch_Subheading).Perform();
            return(new MyPipeline());
        }
 public void GetShouldReturnAvailableCarAdsWithoutAQuery()
 => MyPipeline
 .Configuration()
 .ShouldMap("/CarAds")
 .To <CarAdsController>(c => c.Search(With.Empty <SearchCarAdsQuery>()))
 .Which(instance => instance
        .WithData(CarAdFakes.Data.GetCarAds()))
 .ShouldReturn()
 .ActionResult <SearchCarAdsOutputModel>(result => result
                                         .Passing(model => model
                                                  .CarAds.Count().Should().Be(10)));
 public void GetShouldReturnAllCarAdsWithoutAQuery(int totalCarAds)
 => MyPipeline
 .Configuration()
 .ShouldMap("/CarAds")
 .To <CarAdsController>(c => c.Search(With.Empty <SearchCarAdsQuery>()))
 .Which(instance => instance
        .WithData(A.CollectionOfDummy <CarAd>(totalCarAds)))
 .ShouldReturn()
 .ActionResult <SearchCarAdsOutputModel>(result => result
                                         .Passing(model => model
                                                  .CarAds.Count().Should().Be(totalCarAds)));
 public void ShouldMapShouldThrowExceptionIfAuthorizationFiltersAreNotSet()
 {
     Test.AssertException <RouteAssertionException>(
         () =>
     {
         MyPipeline
         .Configuration()
         .ShouldMap("/Normal/AuthorizedAction")
         .To <NormalController>(c => c.AuthorizedAction());
     },
         "Expected route '/Normal/AuthorizedAction' to match AuthorizedAction action in NormalController but exception was thrown when trying to invoke the pipeline: 'No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action<AuthenticationOptions> configureOptions).'.");
 }
 public void ShouldMapShouldExecuteCustomActionFiltersAndShouldValidateRoutes()
 {
     Test.AssertException <RouteAssertionException>(
         () =>
     {
         MyPipeline
         .Configuration()
         .ShouldMap("/Normal/CustomFiltersAction?throw=true")
         .To <NormalController>(c => c.CustomFiltersAction());
     },
         "Expected route '/Normal/CustomFiltersAction' to match CustomFiltersAction action in NormalController but exception was thrown when trying to invoke the pipeline: 'Exception of type 'System.Exception' was thrown.'.");
 }
 public void ShouldMapShouldThrowExceptionIfFiltersAreNotSet()
 {
     Test.AssertException <RouteAssertionException>(
         () =>
     {
         MyPipeline
         .Configuration()
         .ShouldMap("/Normal/FiltersAction")
         .To <NormalController>(c => c.FiltersAction());
     },
         "Expected route '/Normal/FiltersAction' to match FiltersAction action in NormalController but action could not be invoked because of the declared filters - ValidateAntiForgeryTokenAttribute (Action), UnsupportedContentTypeFilter (Global), SaveTempDataAttribute (Global), ControllerActionFilter (Controller). Either a filter is setting the response result before the action itself, or you must set the request properties so that they will pass through the pipeline.");
 }
        public void SearchShouldReturnAprovedReportsWithoutAQuery()
        => MyPipeline
        .Configuration()
        .ShouldMap("/Reports")

        .To <ReportsController>(c => c.Search(With.Empty <SearchReportsQuery>()))
        .Which(instance => instance
               .WithData(ReporterFakes.Data.GetReporter()))

        .ShouldReturn()
        .ActionResult <SearchReportsOutputModel>(result => result
                                                 .Passing(model => model
                                                          .Reports.Count().Should().Be(10)));
예제 #19
0
        static void Main(string[] args)
        {
            // MyListMethod();
            // MyQueueMethod();
            // MyLinkedListMethod();
            // MyDictionaryMethod();
            // ObservableCollectionSample.ObservableCollectionSample.ObservableCollectionSampleMethod();

            // BitVector32Samples.BitVector32SampleMethod();
            // MyImmutableCollectionMethod();
            MyPipeline.StartPipeline();
            Console.ReadLine();
        }
예제 #20
0
        public void SearchShouldReturnAllApartmentAdsWithoutAQuery(int totalApartmentAds)
        => MyPipeline
        .Configuration()
        .ShouldMap("/ApartmentAds")

        .To <ApartmentAdsController>(c => c.Search(With.Empty <SearchApartmentAdsQuery>()))
        .Which(instance => instance
               .WithData(BrokerFakes.Data.GetBroker(totalApartmentAds: totalApartmentAds)))

        .ShouldReturn()
        .ActionResult <SearchApartmentAdsOutputModel>(result => result
                                                      .Passing(model => model
                                                               .ApartmentAds.Count().Should().Be(totalApartmentAds)));
 public void WhichShouldResolveCorrectSyncAction()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("/Home/Contact/1")
     .To <HomeController>(c => c.Contact(1))
     .Which()
     .ShouldReturn()
     .Ok(ok => ok
         .Passing(result => result
                  .Value
                  .Equals(1)));
 }
 public void WhichShouldResolveCorrectAsyncAction()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("/Home/AsyncMethod")
     .To <HomeController>(c => c.AsyncMethod())
     .Which()
     .ShouldReturn()
     .Ok(ok => ok
         .Passing(result => result
                  .Value
                  .Equals("Test")));
 }
예제 #23
0
        public void SearchShouldReturnAvailableArticlesWithoutAQuery()
        => MyPipeline
        .Configuration()
        .ShouldMap("/Articles")

        .To <ArticlesController>(c => c.Search(With.Empty <SearchArticlesQuery>()))
        .Which(instance => instance
               .WithData(JournalistFakes.Data.GetJournalist()))

        .ShouldReturn()
        .ActionResult <SearchArticlesOutputModel>(result => result
                                                  .Passing(model => model
                                                           .Articles.Count().Should().Be(10)));
예제 #24
0
 public void GetWishlistShouldBeForAuthorizedUsersAndReturnView()
 => MyPipeline
 .Configuration()
 .ShouldMap(request => request
            .WithPath("/Wishlist")
            .WithUser())
 .To <WishlistController>(c => c.Index())
 .Which()
 .ShouldHave()
 .ActionAttributes(attributes => attributes
                   .RestrictingForAuthorizedRequests())
 .AndAlso()
 .ShouldReturn()
 .View();
예제 #25
0
 public static void Init(TestContext context)
 {
     testContext    = context;
     driver         = Driver.Initialize(testContext.Properties["BrowserChromeName"].ToString());
     freshStart     = new FreshStartHome(driver);
     commonhelper   = new WebObjectFunctions(driver);
     newEnroll      = new NewEnrollClient(driver);
     myPipeline     = new MyPipeline(driver);
     apiHelper      = new CommonAPIHelper(driver);
     pipelineSearch = new PipelineSearch(driver);
     freshStartUrl  = ConfigurationManager.AppSettings["FreshStartUrl"];
     freshStart.NavigateToFreshStartHome(driver, freshStartUrl);
     freshStart.NavigateToMyPipelineHome(driver);
 }
예제 #26
0
 public void GetBecomeShouldBeForAuthorizedUsersAndReturnView()
 => MyPipeline
 .Configuration()
 .ShouldMap(request => request
            .WithPath("/Dealers/Become")
            .WithUser())
 .To <DealersController>(c => c.Become())
 .Which()
 .ShouldHave()
 .ActionAttributes(attributes => attributes
                   .RestrictingForAuthorizedRequests())
 .AndAlso()
 .ShouldReturn()
 .View();
 public void WhichShouldResolveCorrectActionFilterLogic()
 {
     MyPipeline
     .Configuration()
     .ShouldMap("/Normal/CustomFiltersAction?controller=true")
     .To <NormalController>(c => c.CustomFiltersAction())
     .Which()
     .ShouldReturn()
     .Ok()
     .AndAlso()
     .ShouldPassForThe <NormalController>(controller =>
     {
         Assert.Equal("ActionFilter", controller.Data);
     });
 }
 public void WhichShouldNotResolveCorrectActionResultWhenFilterSetsIt()
 {
     Test.AssertException <RouteAssertionException>(
         () =>
     {
         MyPipeline
         .Configuration()
         .ShouldMap("/Normal/CustomFiltersAction?result=true")
         .To <NormalController>(c => c.CustomFiltersAction())
         .Which()
         .ShouldReturn()
         .Ok();
     },
         "Expected route '/Normal/CustomFiltersAction' to match CustomFiltersAction action in NormalController but action could not be invoked because of the declared filters - CustomActionFilterAttribute (Action), UnsupportedContentTypeFilter (Global), SaveTempDataAttribute (Global), ControllerActionFilter (Controller). Either a filter is setting the response result before the action itself, or you must set the request properties so that they will pass through the pipeline.");
 }
        public void WhichShouldResolveCorrectAsyncActionWithSetup()
        {
            const string testData = "TestData";

            MyPipeline
            .Configuration()
            .ShouldMap("/Home/AsyncMethod")
            .To <HomeController>(c => c.AsyncMethod())
            .Which()
            .WithSetup(c => c.Data = testData)
            .ShouldReturn()
            .Ok(ok => ok
                .Passing(result => result
                         .Value
                         .Equals(testData)));
        }
예제 #30
0
        public void GetAllValueForClientTwo(IWebDriver driver)
        {
            freshStart     = new FreshStartHome(driver);
            commonhelper   = new WebObjectFunctions(driver);
            newEnroll      = new NewEnrollClient(driver);
            myPipeline     = new MyPipeline(driver);
            apiHelper      = new CommonAPIHelper(driver);
            pipelineSearch = new PipelineSearch(driver);
            string freshStartUrl = ConfigurationManager.AppSettings["FreshStartUrl"];

            newEnroll.NavigateToNewClient(driver, ConfigurationManager.AppSettings["LoanForTwo"]);
            newEnroll.NavigateToClientOption(driver);
            newEnroll.SelectMutipleClient(driver);
            value = freshStart.FreshStartClientInfoClientTwoEmail_TextBox.GetAttribute("value");
            valueClientTwoFirstName = freshStart.FreshStartClientInfoClientTwoFirstName_TextBox.GetAttribute("value");
            valueClientTwoLastName  = freshStart.FreshStartClientInfoClientTwoLastName_TextBox.GetAttribute("value");
        }
        public void WhichShouldNotResolveControllerContextWhenWithMethodsAreCalledInInnerBuilder()
        {
            MyApplication
            .StartsFrom <DefaultStartup>()
            .WithServices(services => services
                          .AddTransient <IInjectedService, InjectedService>());

            const string contextTestKey   = "ControllerContext";
            const string contextTestValue = "Context Value";

            MyPipeline
            .Configuration()
            .ShouldMap("/Pipeline/Action?controller=true")
            .To <PipelineController>(c => c.Action())
            .Which(controller => controller
                   .WithHttpContext(context => context.Features.Set(new AnotherInjectedService()))
                   .WithHttpRequest(request => request.WithHeader(contextTestKey, contextTestValue))
                   .WithUser(user => user.WithUsername(contextTestKey))
                   .WithRouteData(new { Id = contextTestKey })
                   .WithControllerContext(context => context.RouteData.Values.Add(contextTestKey, contextTestValue))
                   .WithActionContext(context => context.ModelState.AddModelError(contextTestKey, contextTestValue))
                   .WithTempData(tempData => tempData.WithEntry(contextTestKey, contextTestValue))
                   .WithSetup(controller => controller.HttpContext.Features.Set(new InjectedService())))
            .ShouldReturn()
            .Ok()
            .AndAlso()
            .ShouldPassForThe <PipelineController>(controller =>
            {
                const string testValue = "ControllerFilter";
                Assert.Equal(testValue, controller.Data);
                Assert.True(controller.RouteData.Values.ContainsKey(testValue));
                Assert.True(controller.RouteData.Values.ContainsKey(contextTestKey));
                Assert.True(controller.RouteData.Values.ContainsKey("Id"));
                Assert.True(controller.ControllerContext.ActionDescriptor.Properties.ContainsKey(testValue));
                Assert.True(controller.ModelState.ContainsKey(testValue));
                Assert.True(controller.ModelState.ContainsKey(contextTestKey));
                Assert.NotNull(controller.HttpContext.Features.Get <PipelineController>());
                Assert.NotNull(controller.HttpContext.Features.Get <InjectedService>());
                Assert.NotNull(controller.HttpContext.Features.Get <AnotherInjectedService>());
                Assert.True(controller.HttpContext.Request.Headers.ContainsKey(contextTestKey));
                Assert.True(controller.TempData.ContainsKey(contextTestKey));
                Assert.True(controller.User.Identity.Name == contextTestKey);
            });

            MyApplication.StartsFrom <DefaultStartup>();
        }