Esempio n. 1
0
        public FirstPage(MainPageModel model)
        {
            InitializeComponent();
            Model = new MainPageModel();
            Model.Event_GridHeaderComplete += new EventHandler <InvokeOperationEventArgs <string> >(GridHeaderComplete);
            Model.init();
            this.DataContext = Model;
            #region 给页面按钮添加图片
            Img_Top.Source      = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Btn_Up.png"), UriKind.Absolute));
            RadBtn_Query.Image  = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Buttons/Query32.png"), UriKind.Absolute));
            RadBtn_Insert.Image = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Buttons/Add32.png"), UriKind.Absolute));
            RadBtn_Update.Image = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Buttons/Edit32.png"), UriKind.Absolute));
            RadBtn_Delete.Image = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Buttons/Delete32.png"), UriKind.Absolute));
            RadBtn_Excel.Image  = new BitmapImage(new Uri(GetUrl.GetAbsoluteUrl("Images/Buttons/Excel32.png"), UriKind.Absolute));
            #endregion


            #region 注册事件
            RadBtn_Query.MouseLeftButtonDown += new MouseButtonEventHandler(RadBtn_Query_MouseLeftButtonDown);
            RadBtn_Query.Click  += new System.Windows.RoutedEventHandler(RadBtn_Query_Click);
            RadBtn_Insert.Click += new System.Windows.RoutedEventHandler(RadBtn_Insert_Click);
            RadBtn_Update.Click += new System.Windows.RoutedEventHandler(RadBtn_Update_Click);
            RadBtn_Delete.Click += new System.Windows.RoutedEventHandler(RadBtn_Delete_Click);
            RadBtn_Excel.MouseLeftButtonDown += new MouseButtonEventHandler(RadBtn_Excel_Click);
            #endregion

            #region 注册model里的事件
            Model.Event_QueryDataSuccess += new EventHandler <ConstsEventArgs>(model_QueryDataSuccess);
            Model.Event_QueryDataFailure += new EventHandler <ConstsEventArgs>(model_QueryDataFailure);
            #endregion
        }
Esempio n. 2
0
 public IActionResult Get()
 {
     return(Ok(_bookBusiness.FindAll().Select(x => (BookVO)GetUrl.GerarLinks(
                                                  x,
                                                  nameof(Get),
                                                  this.HttpContext, _linkGenerator))));
 }
        [TestMethod] public async Task CreateAllGivenTest()
        {
            Assert.Inconclusive();
            // http://www.stefanhendriks.com/2016/05/11/integration-testing-your-asp-net-core-app-dealing-with-anti-request-forgery-csrf-formdata-and-cookies/
            var c = GetRandom.Object <CountryViewModel>();

            c.Alpha3Code = "YYY";
            c.Alpha2Code = "YY";
            c.Name       = "Some name";
            var d = new Dictionary <string, string>();
            var a = GetUrl.ForControllerAction <CountriesController>(x => x.Create());

            d.Add(GetMember.Name <CountryViewModel>(m => m.Alpha3Code), c.Alpha3Code);
            d.Add(GetMember.Name <CountryViewModel>(m => m.Alpha2Code), c.Alpha2Code);
            d.Add(GetMember.Name <CountryViewModel>(m => m.Name), c.Name);
            d.Add(GetMember.Name <CountryViewModel>(m => m.ValidFrom), c.ValidFrom.ToString());
            d.Add(GetMember.Name <CountryViewModel>(m => m.ValidTo), c.ValidTo.ToString());
            var content = new FormUrlEncodedContent(d);

            TestAuthenticationHandler.IsLoggedIn = true;
            var response = await client.PostAsync(a, content);

            Assert.AreEqual(HttpStatusCode.Redirect, response.StatusCode);
            var dbObject = await repository.GetObjectsList();

            Assert.IsNotNull(dbObject);
        }
Esempio n. 4
0
        [TestMethod] public async Task IndexTest()
        {
            var a = GetUrl.ForControllerAction <TController>(x => x.Index(null, null, null, null));

            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);

            var strings = new List <string> {
                $"<form method=\"get\" action=\"/{controller}\"",
                "<div class=\"form-inline col-md-6\">",
                "Find by: <input class=\"form-control\" type=\"text\" name=\"SearchString\"",
                "<input type=\"submit\" value=\"Search\" class=\"btn btn-default\" /> |",
                $"<a href=\"/{controller}\">Back to Full List</a>",
                "<table class=\"table\">",
                "<thead>",
                $"<a class=\"btn btn-default disabled\" href=\"/{controller}?page=0\">",
                $"<a class=\"btn btn-default \" href=\"/{controller}?page=2\">",
                $"<th><a href=\"/{controller}/Edit/",
                $"\">Edit</a> | <a href=\"/{controller}/Details/",
                $"\">Details</a> | <a href=\"/{controller}/Delete/",
                ">Delete</a></th>"
            };

            strings.AddRange(specificStringsToTestInIndexView());
            await testWhenLoggedIn(a, strings.ToArray());
        }
        [TestMethod] public async Task HomeTest()
        {
            var a = GetUrl.ForControllerAction <HomeController>();

            await testControllerAction(a, "<h2>Welcome to SonicBank!</h2>",
                                       "<h3>Please log in to use our services!</h3>");
        }
Esempio n. 6
0
        private async Task deleteTest(string id)
        {
            var a = GetUrl.ForControllerAction <TController>(x => x.Delete(""));

            a = a + $"/{id}";
            await testWhenLoggedOut(a, HttpStatusCode.Redirect);
        }
Esempio n. 7
0
        [TestMethod] public async Task HomeTest()
        {
            var a = GetUrl.ForControllerAction <HomeController>();

            await testControllerAction(a, "<h1>Sentry</h1>", "<h2>Welcome to Sentry</h2>",
                                       "<h2>Download it</h2>");
        }
Esempio n. 8
0
        public bool message(string mobile, string sms)
        {
            GetUrl sendurl = new GetUrl();

            sendurl.SendMessage(mobile, sms);
            return(true);
        }
Esempio n. 9
0
        public async Task <WeatherInformation> ReadWeatherInformation(DateTime date)
        {
            GetUrl getUrl = (attempts) =>
            {
                return($"https://www.wunderground.com/history/daily/{location}/date/{date.ToString("yyyy-M-d")}");
            };

            var htmlDocument = await WebBrowserRequest.Navigate(getUrl, IsDocumentFullyLoaded, this.userInteraction, this.browser);

            if (GetReadings(htmlDocument, date, out List <WeatherReading> readings, out int dummy) &&
                GetLocationInformation(htmlDocument, out double latitude, out double longitude, out int dummy2))
            {
                WeatherInformation daylight = this.timeRangeProvider.GetInformation(this.userInteraction, date, latitude, longitude);

                if (daylight != null)
                {
                    return(new WeatherInformation(
                               daylight.StartTime,
                               daylight.EndTime,
                               readings));
                }
            }

            return(null);
        }
Esempio n. 10
0
        public SchedulePage()
        {
            InitializeComponent();

            GetUrl get = new GetUrl();

            Url      = get.GetScheduleUrl();
            classUrl = get.GetClassUrl();

            _ = ClassGetListAsync();

            GetStringFromKey SchedulegetTextFromKey = new GetStringFromKey("day_key");

            pickerdayofweek.SelectedIndex = (SchedulegetTextFromKey.GetText() == "") ? 0 : int.Parse(SchedulegetTextFromKey.GetText());
            numChanged = WeekCheck(pickerdayofweek.Items[pickerdayofweek.SelectedIndex]);



            myList.ItemTapped += (object sender, ItemTappedEventArgs e) =>
            {
                if (e.Item == null)
                {
                    return;
                }
                ((ListView)sender).SelectedItem = null;
            };

            _ = OnGetListAsync();
        }
Esempio n. 11
0
 public IActionResult GetBook(int id)
 {
     return(Ok(GetUrl.GerarLinks(
                   _bookBusiness.FindById(id),
                   nameof(GetBook),
                   this.HttpContext, _linkGenerator)));
 }
Esempio n. 12
0
        protected async Task createTest(Expression <Func <TController, object> > action,
                                        string controllerName,
                                        string header, string postAction = "create")
        {
            var a = GetUrl.ForControllerAction(action);

            await testWhenLoggedOut(a, HttpStatusCode.Redirect);
        }
Esempio n. 13
0
        public void ValidatePageUrl(string expectedUrl)
        {
            var currentUrl = GetUrl.Contains(expectedUrl);
            var messsage   = $":: URL: {GetTitle} - Expected:{expectedUrl}";

            Assert.IsTrue(currentUrl, $"#Error: {messsage}");
            Console.Out.WriteLine(messsage);
        }
Esempio n. 14
0
        protected async Task editTest(Expression <Func <TController, object> > actionMethod, Func <string> actionName,
                                      Func <string> header, Func <List <string> > stringsToTestInView)
        {
            var id = createDbRecord();
            var a  = GetUrl.ForControllerAction(actionMethod);

            a = a + $"/{id}";
            await testWhenLoggedOut(a, HttpStatusCode.Redirect);
        }
Esempio n. 15
0
        public DelegateBrowserForm()
        {
            wb = new WebBrowser();

            CheckDelegate  = new CheckValue(this.CheckValueMethod);
            SetDelegate    = new SetValue(this.SetValueMethod);
            SubmitDelegate = new SubmitForm(this.SubmitFormMethod);
            ScriptDelegate = new RunScript(this.RunScriptMethod);
            UrlDelegate    = new GetUrl(this.GetUrlMethod);
        }
Esempio n. 16
0
        public DelegateBrowserForm()
        {
            wb = new WebBrowser();

            CheckDelegate = new CheckValue(this.CheckValueMethod);
            SetDelegate = new SetValue(this.SetValueMethod);
            SubmitDelegate = new SubmitForm(this.SubmitFormMethod);
            ScriptDelegate = new RunScript(this.RunScriptMethod);
            UrlDelegate = new GetUrl(this.GetUrlMethod);
        }
Esempio n. 17
0
 public static async Task <HtmlAgilityPack.HtmlDocument> Navigate(
     GetUrl getUrl,
     IsDocumentFullyLoaded isDocumentFullyLoaded,
     IUserInteraction userInteraction,
     IWebBrowser browser)
 {
     using (var request = new WebBrowserRequest(browser, getUrl, isDocumentFullyLoaded, userInteraction))
     {
         return(await request.Navigate());
     }
 }
        public async Task RegisterTest()
        {
            var a = GetUrl.ForControllerAction <AccountController>(x => x.Register(null));

            await testControllerAction(a,
                                       "<h2>Register</h2>",
                                       "<form method=\"post\" action=\"/Account/Register\">",
                                       "<h4>Create a new account</h4>",
                                       "<label for=\"Email\">Email</label>",
                                       "<label for=\"Password\">Password</label>",
                                       "<label for=\"ConfirmPassword\">Confirm password</label>",
                                       "<button style=\"margin-top: 48px\" type=\"submit\" class=\"btn btn-primary btn-block\">Register</button>"
                                       );
        }
        [TestMethod] public async Task CreateTest()
        {
            Assert.Inconclusive();
            var a = GetUrl.ForControllerAction <CountriesController>(x => x.Create());

            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);
            await testWhenLoggedIn(a,
                                   "<h2>Create</h2>",
                                   "<form action=\"/countries/create\" method=\"post\">",
                                   "<h4>Country</h4>",
                                   "<input type=\"submit\" value=Create class=\"btn btn-default\" />",
                                   "<a href=\"/countries\">Back to List</a>"
                                   );
        }
Esempio n. 20
0
        protected async Task createTest(Expression <Func <TController, object> > action,
                                        string controllerName,
                                        string header, string postAction = "create")
        {
            var a = GetUrl.ForControllerAction(action);

            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);
            await testWhenLoggedIn(a,
                                   "<h2>Create</h2>",
                                   $"<form action=\"/{controllerName}/{postAction}\" method=\"post\">",
                                   $"<h4>{header}</h4>",
                                   "<input type=\"submit\" value=Create class=\"btn btn-default\" />",
                                   $"<a href=\"/{controllerName}\">Back to List</a>"
                                   );
        }
        public async Task LoginTest()
        {
            var a = GetUrl.ForControllerAction <AccountController>(x => x.Login(null));

            await testControllerAction(a,
                                       "<h2>Log in</h2>",
                                       "<form method=\"post\" action=\"/Account/Login\">",
                                       "<h4>Use a local account to log in</h4>",
                                       "<label for=\"Email\">Email</label>",
                                       "<label for=\"Password\">Password</label>",
                                       "<label for=\"RememberMe\">",
                                       "<button type=\"submit\" class=\"btn btn-primary btn-block\">Log in</button>",
                                       "<a href=\"/Account/ForgotPassword\">Forgot your password?</a>",
                                       "<a href=\"/Account/Register\">Register as a new user?</a>"
                                       );
        }
Esempio n. 22
0
        private WebBrowserRequest(
            IWebBrowser browser,
            GetUrl getUrl,
            IsDocumentFullyLoaded isDocumentFullyLoaded,
            IUserInteraction userInteraction)
        {
            this.browser = browser;
            this.browser.DocumentCompleted += Browser_DocumentCompleted;
            this.isDocumentFullyLoaded      = isDocumentFullyLoaded;
            this.getUrl          = getUrl;
            this.userInteraction = userInteraction;

            this.manualResetEvent = new ManualResetEvent(false);
            this.htmlDocument     = new HtmlAgilityPack.HtmlDocument();
            this.lockObject       = new object();
        }
Esempio n. 23
0
        private EnterpriseEventCacheDataRequest GetCacheRequestData()
        {
            BatchDetails linkBatchDetails = new BatchDetails()
            {
                Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272"
            };
            BatchStatus linkBatchStatus = new BatchStatus()
            {
                Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272/status"
            };
            GetUrl linkGet = new GetUrl()
            {
                Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272/files/exchangeset123.zip",
            };
            LinksNew links = new LinksNew()
            {
                BatchDetails = linkBatchDetails,
                BatchStatus  = linkBatchStatus,
                GetUrl       = linkGet
            };

            return(new EnterpriseEventCacheDataRequest
            {
                Links = links,
                BusinessUnit = "ADDS",
                Attributes = new List <Attribute> {
                    new Attribute {
                        Key = "Agency", Value = "DE"
                    },
                    new Attribute {
                        Key = "CellName", Value = "DE290001"
                    },
                    new Attribute {
                        Key = "EditionNumber", Value = "1"
                    },
                    new Attribute {
                        Key = "UpdateNumber", Value = "0"
                    },
                    new Attribute {
                        Key = "ProductCode", Value = "AVCS"
                    }
                },
                BatchId = "d6cd4d37-4d89-470d-9a33-82b3d7f54b6e",
                BatchPublishedDate = DateTime.UtcNow
            });
        }
        [TestMethod] public async Task DetailsTest()
        {
            Assert.Inconclusive();
            var a = GetUrl.ForControllerAction <CountriesController>(x => x.Details(""));

            a = a + "/AFG";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);
            await testWhenLoggedIn(a,
                                   "<h2>Details</h2>",
                                   "AFG</div></div>",
                                   "AF</div></div>",
                                   "Afghanistan</div></div>",
                                   "<h4>Country</h4>",
                                   "<a href=\"/countries/Edit/AFG\">Edit</a>",
                                   "<a href=\"/countries\">Back to List</a>"
                                   );
        }
Esempio n. 25
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            output.Content.Clear();
            string id = "tree";

            if (Id.IsPresent())
            {
                id = $"tree-{Id}";
            }
            JsTree tree = new JsTree(_dataAccessor, _rbacService, _applicationContext, id);

            tree.SetAsync(IsAsync);
            if (IsOrgdept)
            {
                tree.IsOrgDept();
            }
            if (GetUrl.IsPresent())
            {
                tree.SetUrl(GetUrl);
            }
            if (EditUrl.IsPresent())
            {
                tree.SetEditUrl(EditUrl);
            }
            if (JsonData.IsPresent())
            {
                tree.SetJsonData(JsonData);
            }
            if (TreeMode != null)
            {
                tree.SetTreeModel(TreeMode);
            }
            if (OnOpenNoded.IsPresent())
            {
                tree.OnOpenNodedEvent(OnOpenNoded);
            }
            if (OnLoaded.IsPresent())
            {
                tree.OnLoadedEvent(OnLoaded);
            }
            tree.SetPluginDnd(PluginDnd);
            tree.SetPluginCheckBox(PluginCheckbox);
            output.Content.AppendHtml(tree.ToString());
        }
        private async Task deactivateTest(string id)
        {
            var a = GetUrl.ForControllerAction <BankAccountController>(x => x.Deactivate(""));

            a = a + $"/{id}";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);

            var strings = new List <string> {
                "<h2>Deactivate</h2>",
                $"<form action=\"/{controller}/deactivate/{id}\" method=\"post\">",
                $"<h4>{id}</h4>",
                "<input type=\"submit\" value=Deactivate &raquo class=\"btn btn-primary btn-sm\" />",
                $"<a href=\"/\">Back to home page</a>"
            };

            strings.AddRange(specificStringsToTestInView);
            await testWhenLoggedIn(a, strings.ToArray());
        }
Esempio n. 27
0
        private async Task deleteTest(string id)
        {
            var a = GetUrl.ForControllerAction <TController>(x => x.Delete(""));

            a = a + $"/{id}";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);

            var strings = new List <string> {
                "<h2>Delete</h2>",
                $"<form action=\"/{controller}/delete/{id}\" method=\"post\">",
                $"<h4>{detailsViewCaption}</h4>",
                "<input type=\"submit\" value=Delete class=\"btn btn-default\" />",
                $"<a href=\"/{controller}\">Back to List</a>"
            };

            strings.AddRange(specificStringsToTestInView);
            await testWhenLoggedIn(a, strings.ToArray());
        }
        [TestMethod] public async Task DeleteTest()
        {
            Assert.Inconclusive();
            var a = GetUrl.ForControllerAction <CountriesController>(x => x.Delete(""));

            a = a + "/AFG";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);
            await testWhenLoggedIn(a,
                                   "<h2>Delete</h2>",
                                   "AFG</div></div>",
                                   "AF</div></div>",
                                   "Afghanistan</div></div>",
                                   "<form action=\"/countries/delete/AFG\" method=\"post\">",
                                   "<h4>Country</h4>",
                                   "<input type=\"submit\" value=Delete class=\"btn btn-default\" />",
                                   "<a href=\"/countries\">Back to List</a>"
                                   );
        }
Esempio n. 29
0
        [TestMethod] public async Task DetailsTest()
        {
            var id = createDbRecord();
            var a  = GetUrl.ForControllerAction <TController>(x => x.Details(""));

            a = a + $"/{id}";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);

            var strings = new List <string> {
                "<h2>Details</h2>",
                $"<h4>{detailsViewCaption}</h4>",
                $"<a href=\"/{controller}/Edit/{id}\">Edit</a>",
                $"<a href=\"/{controller}\">Back to List</a>"
            };

            strings.AddRange(specificStringsToTestInView);
            await testWhenLoggedIn(a, strings.ToArray());
        }
        [TestMethod] public async Task EditTest()
        {
            Assert.Inconclusive();
            var a = GetUrl.ForControllerAction <CountriesController>(x => x.Edit(""));

            a = a + "/AFG";
            await testWhenLoggedOut(a, HttpStatusCode.Unauthorized);
            await testWhenLoggedIn(a,
                                   "<h2>Edit</h2>",
                                   "type=\"hidden\" value=\"AFG\"",
                                   "value=\"AF\"",
                                   "value=\"Afghanistan\"",
                                   "<form action=\"/countries/edit/AFG\" method=\"post\">",
                                   "<h4>Country (AFG)</h4>",
                                   "<input type=\"submit\" value=Save class=\"btn btn-default\" />",
                                   "<a href=\"/countries\">Back to List</a>"
                                   );
        }
Esempio n. 31
0
        protected async Task createAllGivenTest <T>(Func <object> createRandom, Expression <Func <T, object> > action)
            where T : Controller, ISentryController
        {
            var o = createRandom();
            var a = GetUrl.ForControllerAction(action);

            TestAuthenticationHandler.IsLoggedIn = true;
            var response = await client.GetAsync(a);

            response.EnsureSuccessStatusCode();
            var d       = createHttpPostContext(o);
            var content = new FormUrlEncodedContent(d);

            TestAuthenticationHandler.IsLoggedIn = true;
            response = await client.PostAsync(a, content);

            Assert.AreEqual(HttpStatusCode.Redirect, response.StatusCode);
            await validateEntityInRepository(o);
        }