protected void Button1_Click(object sender, EventArgs e) { // Reset the database tables DummyData dummyData = new DummyData(); dummyData.MakeTables(); dummyData.InsertBirdRecords(); dummyData.InsertMemberRecords(); dummyData.InsertBirdMemberRecords(); Label1.Text = "Database has been reset"; Response.Redirect("Database.aspx"); }
public void Should_read_number_to_invariant() { var sut = new Json2SquidexConverter("number"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["number"] = new Dictionary <string, JToken> { ["iv"] = 1234 } }; EqualJson(expected, actual); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // global cors policy app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); DummyData.Initialize(app); }
public void Should_read_string_to_invariant() { var sut = new Json2SquidexConverter("text"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["text"] = new Dictionary <string, JToken> { ["iv"] = "Hello World" } }; EqualJson(expected, actual); }
public void Should_read_string_to_nested_array() { var sut = new Json2SquidexConverter("json.iv.1.0=text"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["json"] = new Dictionary <string, JToken> { ["iv"] = new JArray(null, new JArray("Hello World")) } }; EqualJson(expected, actual); }
public void Should_read_multiple_values_to_array() { var sut = new Json2SquidexConverter("json.iv.1=text,json.iv.0=number"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["json"] = new Dictionary <string, JToken> { ["iv"] = new JArray(1234, "Hello World") } }; EqualJson(expected, actual); }
public void Should_read_object_to_invariant() { var sut = new Json2SquidexConverter("obj"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["obj"] = new Dictionary <string, JToken> { ["iv"] = new JObject(new JProperty("Squidex", "CLI")) } }; EqualJson(expected, actual); }
public void Should_read_array_to_invariant() { var sut = new Json2SquidexConverter("array"); var actual = sut.ReadAll(jsonReader).First(); var expected = new DummyData { ["array"] = new Dictionary <string, JToken> { ["iv"] = new JArray("Squidex", "CLI") } }; EqualJson(expected, actual); }
// 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(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); app.UseCors("AllowOrigin"); DummyData.Initialize(app); }
public void GetFileTest() { // arrange int size = 1024; byte[] bytes = new byte[size]; string url = DummyFileHelper.GetFileUrl(size); var dummyData = DummyData.GenerateOrderedBytes(size); // act var headers = ReadAndGetHeaders(url, bytes); // assert Assert.IsTrue(dummyData.SequenceEqual(bytes)); Assert.AreEqual(size.ToString(), headers["Content-Length"]); Assert.AreEqual(contentType, headers["Content-Type"]); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext ctx) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseCors(builder => builder.WithOrigins("*").AllowAnyHeader() ); app.UseStaticFiles(); var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options.Value); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "ZenithSocietyCore V1"); }); if (ctx.Database.IsSqlite()) { if (ctx.Database.EnsureCreated()) { DummyData.Initialize(ctx, app.ApplicationServices); } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <IdentityUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); DummyData.Initialize(app, userManager).Wait(); }
protected override void Seed(TrackerModuleV1._0.Data.PTMContex context) { // This method will be called after migrating to the latest version. context.Projects.AddOrUpdate( p => p.ProjectName, DummyData.getProjects().ToArray()); context.SaveChanges(); context.Users.AddOrUpdate( u => new { u.FirstName, u.LastName }, DummyData.getUsers().ToArray()); context.SaveChanges(); context.Parts.AddOrUpdate( p => p.PartName, DummyData.getParts(context).ToArray()); context.SaveChanges(); context.Levels.AddOrUpdate( p => p.levelId, DummyData.getLevels(context).ToArray()); context.SaveChanges(); AddOrUpdateUser(context, "Wafer Sorter", "Abienash"); AddOrUpdateUser(context, "Wafer Sorter", "Leo"); AddOrUpdateUser(context, "Bakeout Chamber", "Leo"); AddOrUpdateUser(context, "Carbon Nanotube CVD Chamber", "Devinda"); AddOrUpdateUser(context, "Process Kit Transporter", "Danny"); AddOrUpdateUser(context, "Bakeout Chamber", "Devinda"); AddorUpdatePart(context, "Wafer Sorter", "ScrewDriver"); AddorUpdatePart(context, "Process Kit Transporter", "BreadBoard"); AddorUpdatePart(context, "Process Kit Transporter", "ScrewDriver"); //AddOrUpdateProject_Level(context, "Wafer Sorter", "PRO00101"); //AddOrUpdateProject_Level(context, "Wafer Sorter", "PRO00102"); //AddOrUpdateProject_Level(context, "Wafer Sorter", "PRO00103"); AddOrUpdateLevel_Part(context, "PRO00101", "ScrewDriver"); AddOrUpdateLevel_Part(context, "PRO00101", "BreadBoard"); AddOrUpdateLevel_Part(context, "PRO00201", "BreadBoard"); context.SaveChanges(); //PRO00201 }
private void TestStreamIntegrity(int streamSize, long maximumBytesPerSecond) { // arrange byte[] data = DummyData.GenerateOrderedBytes(streamSize); byte[] copiedData = new byte[streamSize]; using Stream stream = new ThrottledStream(new MemoryStream(), maximumBytesPerSecond); // act stream.Write(data, 0, data.Length); stream.Seek(0, SeekOrigin.Begin); stream.Read(copiedData, 0, copiedData.Length); // assert Assert.AreEqual(streamSize, data.Length); Assert.AreEqual(streamSize, copiedData.Length); Assert.IsTrue(data.SequenceEqual(copiedData)); }
// 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(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); DummyData.Initialize(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppIdentityDbContext context, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // global cors policy app.UseCors(x => x .SetIsOriginAllowed(origin => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Microservice API V1"); }); // auto run migration RunMigration(app); DummyData.Initialize(context, userManager, roleManager).Wait(); }
public IEnumerable <DummyData> ReadAll(JsonTextReader jsonReader) { if (jsonReader.Read() && jsonReader.TokenType == JsonToken.StartArray) { while (jsonReader.Read()) { if (jsonReader.TokenType == JsonToken.EndArray) { break; } DummyData data = ReadOne(jsonReader); yield return(data); } } }
public void TestSetValidPositionWhenStorageChanged() { // arrange var nextPosition = 512; var chunk = new Chunk(0, 1024) { Position = 1, Storage = Storage }; // act Storage.WriteAsync(DummyData.GenerateRandomBytes(nextPosition), 0, nextPosition); chunk.SetValidPosition(); // assert Assert.AreEqual(nextPosition, chunk.Position); }
public virtual void Initial() { var testData = DummyData.GenerateOrderedBytes(DummyFileHelper.FileSize16Kb); _package = new DownloadPackage() { FileName = DummyFileHelper.SampleFile16KbName, Address = DummyFileHelper.GetFileWithNameUrl(DummyFileHelper.SampleFile16KbName, DummyFileHelper.FileSize16Kb), Chunks = new ChunkHub(Configuration).ChunkFile(DummyFileHelper.FileSize16Kb, 8), TotalFileSize = DummyFileHelper.FileSize16Kb }; foreach (var chunk in _package.Chunks) { chunk.Storage.WriteAsync(testData, (int)chunk.Start, (int)chunk.Length); } }
protected override void Seed(Infrastructure.RecordSheetDBContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. var students = DummyData.GetStudents(); var courses = DummyData.GetCourses(); var grades = DummyData.GetGrades(); var depts = DummyData.GetDepartments(); context.Set <Student>().AddRange(students); context.Set <Course>().AddRange(courses); context.Set <Grade>().AddRange(grades); context.Set <Department>().AddRange(depts); }
public IActionResult Excel() { var comlumHeadrs = new string[] { "Employee Id", "Name", "Position", "Salary", "Joined Date" }; byte[] result; using (var package = new ExcelPackage()) { // add a new worksheet to the empty workbook var worksheet = package.Workbook.Worksheets.Add("Current Employee"); //Worksheet name using (var cells = worksheet.Cells[1, 1, 1, 5]) //(1,1) (1,5) { cells.Style.Font.Bold = true; } //First add the headers for (var i = 0; i < comlumHeadrs.Count(); i++) { worksheet.Cells[1, i + 1].Value = comlumHeadrs[i]; } //Add values var j = 2; foreach (var employee in DummyData.GetEmployeeData()) { worksheet.Cells["A" + j].Value = employee.Id; worksheet.Cells["B" + j].Value = employee.Name; worksheet.Cells["C" + j].Value = employee.Position; worksheet.Cells["D" + j].Value = employee.Salary.ToString("$#,0.00;($#,0.00)"); worksheet.Cells["E" + j].Value = employee.JoinedDate.ToString("MM/dd/yyyy"); j++; } result = package.GetAsByteArray(); } return(File(result, "application/ms-excel", $"Employee.xlsx")); }
protected override void Seed(InventoryManagement.Data.InventoryManagementContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // context.Employees.AddOrUpdate( e => e.Id, DummyData.getEmployees(context).ToArray()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseOpenApi(); app.UseSwaggerUi3(); app.UseHttpsRedirection(); app.UseRouting(); app.UseCors(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); DummyData.Initialize(app); }
public async Task MoveNextAsync_Should_NotChangeStateProperty_When_StepIsNotSuccessful() { var steps = new List <IStateMachineStep <int, DummyData> > { new SettableStep(0, false), new SettableStep(1, true) }; var data = new DummyData(); var machine = new StateMachine <int, DummyData>(steps, 0, data); Assert.Equal(0, machine.State); Assert.False(await machine.MoveNextAsync()); Assert.Equal(0, machine.State); Assert.False(await machine.MoveNextAsync()); Assert.Equal(0, machine.State); Assert.False(await machine.MoveNextAsync()); }
protected override void Seed(BizHacksApp.Models.ApplicationDbContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // context.Products.AddOrUpdate( p => p.ProductId, DummyData.getProducts().ToArray()); context.SaveChanges(); }
public void GetFileWithoutHeaderTest() { // arrange int size = 2048; byte[] bytes = new byte[size]; string filename = "testfilename.dat"; string url = DummyFileHelper.GetFileWithoutHeaderUrl(filename, size); var dummyData = DummyData.GenerateOrderedBytes(size); // act var headers = ReadAndGetHeaders(url, bytes); // assert Assert.IsTrue(dummyData.SequenceEqual(bytes)); Assert.IsNull(headers["Content-Length"]); Assert.IsNull(headers["Content-Type"]); }
/// <summary> /// This searches the database for a particular item, based on their search terms /// </summary> /// <param name="searchTerms"></param> /// <returns></returns> public async static Task <List <Product> > SearchForProduct(string searchTerms) { searchTerms = searchTerms.ToLower(); if (isDebug) { return(DummyData.GetProdutcs().Where(xProduct => xProduct.name.ToLower().Contains(searchTerms)).ToList()); } else { var listToSend = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("TERM", searchTerms) }; string serverResponse = await MiddlewareHTTPClient.SendQuery("searchProducts.jsp", listToSend); return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <Product> >(serverResponse)); } }
public void TestStreamRead() { using (Stream src = new ThrottledStream(new MemoryStream(DummyData.GenerateRandomBytes(1024)), 256)) { src.Seek(0, SeekOrigin.Begin); byte[] buf = new byte[256]; int read = 1; int start = Environment.TickCount; while (read > 0) { read = src.Read(buf, 0, buf.Length); } int elapsed = Environment.TickCount - start; Assert.GreaterOrEqual(elapsed, 4000); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } //if (!(context.Database.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists()) //{ // DummyData.Initialize(context, userManager, roleManager).Wait();// seed here //} context.Database.Migrate(); DummyData.Initialize(context, userManager, roleManager).Wait();// seed here app.UseStatusCodePagesWithReExecute("/StatusCode/{0}"); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), "node_modules")), RequestPath = "/node_modules" }); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ApplicationDbContext context, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseCors("EmailPolicy"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseSwagger(); // https://localhost:<port>/swagger app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "VotingTool API V1"); }); var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options.Value); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DummyData.Initialize(app).Wait(); StateInit.Initialize(context); ThemesInit.Initialize(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Art It Forward API"); options.RoutePrefix = "api"; }); app.UseCors(options => options.AllowAnyOrigin()); DummyData.Initialize(context, userManager, roleManager).Wait(); }
public void ExtractValueShouldReturnItemPropertyValue() { var executer = new ExpressionNodeExecuterStub(Mock.Create<INodeVisitor>()); var data = new DummyData { Child = new DummyData { Value = "Value" } }; var result = executer.ExtractValue(SourceFieldSetNames.Item, "Child.Value", data); Assert.AreEqual("Value", result); }