private static string GetRepositoryPath(string remoteUrl, StaticServer address) { string repositoryPath; // Remove the server's address from the start of the URL. // Note that the remote URL and both URLs in the server // address have been normalized by this point. if (remoteUrl.StartsWith(address.Http, StringComparison.Ordinal)) { repositoryPath = remoteUrl.Substring(address.Http.Length); } else { repositoryPath = address.Ssh is not null?remoteUrl.Substring(address.Ssh.Length) : ""; } // The server address we matched against may not have ended // with a slash (for HTTPS paths) or a colon (for SSH paths), // which means the path might start with that. Trim that off now. if (repositoryPath.Length > 0) { if (repositoryPath[0] == '/' || repositoryPath[0] == ':') { repositoryPath = repositoryPath.Substring(1); } } if (repositoryPath.EndsWith(".git", StringComparison.Ordinal)) { repositoryPath = repositoryPath.Substring(0, repositoryPath.Length - 4); } return(repositoryPath); }
//private MiddlewareSection section; public ServersDataProvider() { if (_provider == null) { _provider = DbConnectionProvider.CreateDbProvider(ConnectKey); var command = _provider.CreateCommandStruct("StaticServer", CommandMode.Inquiry, "ServerId,Name,Ip,Port"); command.Parser(); using (var dr = _provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { var serversDatas = new ShareCacheStruct <StaticServer>(); while (dr.Read()) { StaticServer oneServerModel = new StaticServer(); oneServerModel.ServerId = Convert.ToInt32(dr["ServerId"]); oneServerModel.Name = dr["Name"].ToString(); oneServerModel.Ip = dr["Ip"].ToString(); oneServerModel.Port = Convert.ToInt32(dr["Port"]); //ServerList.Add(oneServerModel); serversDatas.Add(oneServerModel); } } //this.AddATestCache(); } }
private static StaticServer NormalizeServerUrls(StaticServer address) { string http; string?ssh; http = UrlHelpers.Normalize(address.Http); ssh = address.Ssh is not null?UrlHelpers.Normalize(address.Ssh) : null; return(new StaticServer(http, ssh)); }
private void AddATestCache() { var serversDatas = new ShareCacheStruct <StaticServer>(); { StaticServer oneServerModel = new StaticServer(); oneServerModel.ServerId = 5; oneServerModel.Name = "MQ"; oneServerModel.Ip = "127.0.0.1"; oneServerModel.Port = 9001; serversDatas.Add(oneServerModel); } }
private static bool IsMatch(string url, StaticServer server) { url = UrlHelpers.Normalize(url); if (url.StartsWith(UrlHelpers.Normalize(server.Http), StringComparison.Ordinal)) { return(true); } if ((server.Ssh is not null) && url.StartsWith(UrlHelpers.Normalize(server.Ssh), StringComparison.Ordinal)) { return(true); } return(false); }
public static bool Start() { var config = GetConfig(); var startResult = StaticServer <AccountMock> .Start(config); Logger.LogEntry("SERV CONTROL", startResult == ServerStartStatus.Ok ? LogLevel.Info : LogLevel.Error, $"Start result: {startResult}"); StaticServer <AccountMock> .AddRequestProcessor(new RequestProcessor <AccountMock> { AuthorizationRequired = false, Handler = (account, request) => { Logger.LogEntry("CONTENT", LogLevel.Info, $"{request.ContentType} (== null: {request.ContentType == null})"); return(Task.FromResult(new HandlerResult(HttpStatusCode.OK, null))); }, SubUri = "content", Method = HttpMethod.Get }); return(startResult == ServerStartStatus.Ok); }
public void GetCountTest() { //arrange int readCount = 10000; int writeCount = 1000; var tasks = new List <Task>(); //act for (int i = 0; i < 1000; i++) { for (int j = 0; j < 10; j++) { tasks.Add( Task.Factory.StartNew((() => StaticServer.GetCount()))); } tasks.Add( Task.Factory.StartNew(() => StaticServer.AddToCount(1))); } Task.WaitAll(tasks.ToArray()); //assert Assert.AreEqual(1000, StaticServer.GetCount()); }
public bool DoesFileExist(string fileName) { return(IO.File.Exists(StaticServer.MapPath("~/bam/less/" + fileName))); }
public string GetFileContents(string fileName) { return(IO.File.ReadAllText(StaticServer.MapPath("~/bam/less/" + fileName))); }
public byte[] GetBinaryFileContents(string fileName) { return(IO.File.ReadAllBytes(StaticServer.MapPath("~/bam/less/" + fileName))); }
private static Matcher CreateStaticServerMatcher(StaticServer server) { return((url) => IsMatch(url, server) ? server : null); }
public UrlInfo(string filePath, StaticServer server, PartialSelectedRange selection) { FilePath = filePath; Server = server; Selection = selection; }
public static void Main(string[] args) { var server = new StaticServer(); server.Serve(); }
public static void Stop() => StaticServer <AccountMock> .Stop();
void Check(IWebDriver browser, StaticServer server, string selectorName, Func <string, By> functionUnderTest, bool checkEnforcesUniqueness) { given("using css selector " + selectorName, () => { describe("BySizzle.CssSelector can find elements by Sizzle CSS selector", delegate { arrange(() => browser.Navigate().GoToUrl(server.UrlFor("HelloWorld.html"))); it("can be used with FindElements", delegate { expect(() => browser.FindElements(functionUnderTest("div:contains('Hello')")).Count() == 1); expect(() => browser.FindElements(functionUnderTest("li.last_li")).Count() == 1); expect(() => browser.FindElements(functionUnderTest("div:contains('Hello'), li.last_li")).Count() == 2); }); it("can be used with FindElement", delegate { expect(() => browser.FindElement(functionUnderTest("div:contains('Hello')")) != null); }); it("can handle special characters", delegate { expect(() => browser.FindElement(functionUnderTest("li:contains('\"quotes\"')")) != null); expect(() => browser.FindElements(functionUnderTest("span:contains('phrase with spaces')")).Count() == 1); expect( () => browser.FindElements(functionUnderTest("span:contains('phrase with spaces, and commas.')")).Count() == 1); expect(() => browser.FindElements(functionUnderTest("input#fee-fi_foe-fum")).Count() == 1); expect(() => browser.FindElements(functionUnderTest("input[value='Hello world']")).Count() == 1); //expect(() => browser.FindElements(By.CssSelector("input[value='Hello, world.']")).Count() == 1); expect(() => browser.FindElements(functionUnderTest("input[value='Hello, world.']")).Count() == 1); }); it("reports a useful error if the element is not found", delegate { var e = Assert.Throws <NoSuchElementException>( delegate { browser.FindElement(functionUnderTest("div:contains('This solves everything')")); }); expect( () => e.Message.Contains( "Could not find element matching css selector \"div:contains('This solves everything')\"")); }); }); describe("BySizzle.CssSelector can be used transitively", delegate { arrange(() => browser.Navigate().GoToUrl(server.UrlFor("somepage.html"))); it("matches descendant nodes", delegate { expect( () => browser.FindElement(functionUnderTest("ul")).FindElement(functionUnderTest("li:contains('LIST ITEM')")) != null); }); it("does not match nondescendant nodes", delegate { By paragraphFinder = functionUnderTest("p:contains('PARAGRAPH')"); expect(() => browser.FindElement(paragraphFinder) != null); Assert.Throws <NoSuchElementException>( delegate { expect(() => browser.FindElement(functionUnderTest("ul")).FindElement(paragraphFinder) == null); }); }); }); if (checkEnforcesUniqueness) { when("matching an ambiguous selector", () => { arrange(() => browser.Navigate().GoToUrl(server.UrlFor("HelloWorld.html"))); var selector = "li"; then("a useful exception is thrown", () => { var exception = Assert.Throws <InvalidOperationException>(() => { browser.FindElement(functionUnderTest(selector)); }); expect(() => exception.Message.Contains("More than one element matched selector \"li\".")); }); }); } }); }