public void Test3() { Solidbase list = new Solidbase("Random"); var e = list.Last(); e.lol = "epic"; }
public void Test2() { Solidbase list = new Solidbase("Random"); var e = list.First(); list.Remove(e); }
public void Test4() { Solidbase list = new Solidbase("Random"); //list.Add(new { Id = list.NextId, content = "rainbow" }); var latest = list.Last(); latest.newStuff = "something else"; }
public void Test5() { Solidbase <Product> list = new Solidbase <Product>(); list.Add(new Product { Name = "Something", Price = 520.4 }); var storedProduct = list.Last(x => x.Name == "Something"); Assert.IsNotNull(storedProduct); }
public void Benchmark() { Run("1000 Product Inserts", () => { Solidbase list = new Solidbase <Product>(); for (int i = 0; i < 1000; i++) { list.Add(new Product { Name = "Something", Price = i }); } Assert.IsTrue(list.Count > 999); }); Run("Load 1000 Products", () => { Solidbase list2 = new Solidbase <Product>(); Assert.IsTrue(list2.Count > 999); }); }
public void Test1() { using (Solidbase list = new Solidbase("Random")) { //list.Add(new { count = 1 }); for (int i = 0; i < 8; i++) { list.Add(new { count = i }); } } /*list.Add(new { Id = 1, anotherValue = "awesome" }); * var e = list.First(); * e.something = "lol"; * var g = list.FirstOrDefault(x => x.something == "lol"); * Assert.IsTrue(g != null); * list.Add(new { Id = 40, epic = true }); * list.Remove(list.First());*/ }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseWire(env); Solidbase.Strategy = () => new SqlConnection("Server=.\\SQLEXPRESS;Database=NewSolidb;Trusted_Connection=True;"); API.GET("/api/{Type}", x => { Solidbase list = new Solidbase(x.Parameters.Type); return(list.ToList()); }); API.GET("/api/{Type}/{Id}", x => { Solidbase list = new Solidbase(x.Parameters.Type); return(list.FirstOrDefault(z => z.Id == x.Parameters.Id)); }); API.POST("/api/{Type}", x => { Solidbase list = new Solidbase(x.Parameters.Type); list.Add(x.Body.As <dynamic>()); return(list.ToList()); }); API.DELETE("/api/{Type}/{Id}", x => { Solidbase list = new Solidbase(x.Parameters.Type); var itm = list.FirstOrDefault(z => z.Id == x.Parameters.Id); list.Remove(itm); return(true); }); //API.Plugins.AddJwt(x => x.Username == x.Password, JwtMode.Session); API.Conditions.Add("Authentication", x => x.HttpContext.User.Identity.IsAuthenticated); API.GET("/peep", x => "Hello There..", API.Conditions["Authentication"]); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseWire(env); Solidbase.Strategy = () => new SqlConnection("Server=.\\SQLEXPRESS;Database=WireSolidbFusion;Trusted_Connection=True;"); Solidbase users = new Solidbase <User>(); API.Plugins.AddJwt(x => new Solidbase <User>().Any(g => g.UserName == x.UserName && g.Password == x.Password), JwtMode.Header | JwtMode.Session); API.RULE("/admin/{#path}", x => (x.HttpContext.User.Identity.IsAuthenticated ? null : new Redirect("/login/"))); API.GET("/login/", x => new View("Login")); API.POST("/login/", x => { if (API.Call(HttpMethod.POST, "/token", x) is TokenValidationModel) { return(new Redirect("/admin/")); } else { return(new Redirect("/login/")); } }); API.GET("/admin/", x => new View("Admin", new IndexModel { })); //API.Plugins.AddJwt(x => x.Username == x.Password, JwtMode.Header | JwtMode.Session); //API.GET("/admin", x => new View("Admin", new IndexModel { })); /*API.RULE("/admin/{#path}", x => (x.HttpContext.User.Identity.IsAuthenticated ? null : new { Message = "Not authenticated." })); * // Admin * API.GET("/login", x => * { * return new View("login", new IndexModel { Name = "This is the login screen" }); * }); * API.GET("/admin/blog", x => * { * return new View("blog", new IndexModel { Name = "This is the blog screen" }); * }); * API.GET("/admin/pages", x => * { * return new View("pages", new IndexModel { Name = "This is the pages screen" }); * }); * API.GET("/admin/media", x => * { * return new View("media", new IndexModel { Name = "This is the media screen" }); * }); * API.GET("/admin/menus", x => * { * return new View("menus", new IndexModel { Name = "This is the menus screen" }); * });*/ /*API.GET("/file/{filename}", x => * { * return new ContentResult(x.Parameters.filename, "image/png"); * }); * * API.POST("/upload", x => * { * // TODO. get the file content from the httpContext * var newFileName = string.Empty; * * if (x.HttpContext.Request.Form.Files != null) * { * var fileName = string.Empty; * * var files = x.HttpContext.Request.Form.Files; * * foreach (var file in files) * { * if (file.Length > 0) * { * //Getting FileName * fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); * * //Getting file Extension * var FileExtension = Path.GetExtension(fileName); * * // concating FileName + FileExtension * newFileName = fileName + FileExtension; * * // Combines two strings into a path. * fileName = Path.Combine(API.env.WebRootPath, "") + $@"\{newFileName}"; * * using (FileStream fs = System.IO.File.Create(fileName)) * { * file.CopyTo(fs); * fs.Flush(); * } * } * } * } * return new { OK = 200 }; * });*/ }
public static void ReportBenchmark(string name, double duration) { Solidbase list = new Solidbase <Benchmark>(); //list.Add(new Benchmark { Id = list.NextId, Name = name, Duration = duration }); }