public OrgConfig(OrganizationConfig organizationConfig) : base(organizationConfig) { if (organizationConfig == null) { throw new ArgumentNullException("organizationConfig"); } this.OriginalOrganizationConfig = organizationConfig; }
public void JustLine100000WithTasks() { int n = 100000; var departmentBuilder = new DepartmentBuilder(n, n); var organizationConfig = new OrganizationConfig() { StartDepartment = 1, EndDepartment = n, NumberOfDepartments = n, NumberOfStamps = n, }; for (int i = 0; i < n; i++) { int j = (i + 1) % n; organizationConfig.Departments.Add ( departmentBuilder.GetDepartment(i + 1, j + 1, j + 1) ); } var organization = new Organization(organizationConfig); List <Task> tasks = new List <Task>(); for (int i = 1; i <= n / 100; i++) { var i1 = i; tasks.Add(new Task(() => { var a = organization.GetResult(i1); Assert.IsNotNull(a); Assert.IsNotNull(a.Checklists); Assert.IsTrue(a.Checklists.Count == 1); var uncheckedStamps = a.Checklists[0].GetAllUncheckedStamps(); if (i1 == n) { Assert.IsTrue(uncheckedStamps.Count == 1 && uncheckedStamps[0] == 1); } else { foreach (var stamp in uncheckedStamps) { Assert.IsTrue(stamp > i1); } } Assert.IsTrue(a.Status == DepartmentStatus.Visited); })); tasks[i - 1].Start(); } Task.WaitAll(tasks.ToArray()); }
public void SimpleCycle() { var departmentBuilder = new DepartmentBuilder(6, 5); var organizationConfig = new OrganizationConfig() { StartDepartment = 1, EndDepartment = 6, NumberOfDepartments = 6, NumberOfStamps = 5, }; for (int i = 0; i < 4; i++) { int j = (i + 1) % 5; organizationConfig.Departments.Add ( departmentBuilder.GetDepartment(i + 1, j + 1, j + 1) ); } organizationConfig.Departments.Add ( departmentBuilder.GetDepartment(5, 5, 1, 1, 5, 1, 6) ); organizationConfig.Departments.Add(departmentBuilder.GetDepartment(1, 2, 1)); var organization = new Organization(organizationConfig); for (int i = 1; i <= 6; i++) { var a = organization.GetResult(i); Assert.IsNotNull(a); Assert.IsNotNull(a.Checklists); foreach (var aChecklist in a.Checklists) { var ch = a.Checklists[0].GetAllUncheckedStamps(); if (a.Status == DepartmentStatus.InCycle) { Assert.IsNotNull(ch); Assert.IsTrue(a.Checklists.Count == 2 || i == 4 || i == 5); } } Assert.IsTrue(a.Status == DepartmentStatus.InCycle || a.Status == DepartmentStatus.Inaccessible); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var appInsightsConfig = new AppInsightsConfig { InstrumentationKey = Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"] }; services.AddSingleton(appInsightsConfig); services.AddApplicationInsightsTelemetry(appInsightsConfig.InstrumentationKey); var apiConfig = new ApiConfig { BaseUrl = Configuration["ApiUrl"] }; services.AddSingleton(apiConfig); var orgConfig = new OrganizationConfig { Logo = Configuration["OrganizationLogo"], Name = Configuration["OrganizationName"], Url = Configuration["OrganizationWebSiteUrl"], }; services.AddSingleton(orgConfig); var appConfig = new AppConfig { ApiConfig = apiConfig, AppInsights = appInsightsConfig, Organization = orgConfig, Customizable = Configuration["Customizable"].Equals("true", StringComparison.InvariantCultureIgnoreCase) }; services.AddSingleton(appConfig); services.AddSingleton <IFileProvider>(new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
public void JustLine10000() { int n = 10000; var departmentBuilder = new DepartmentBuilder(n, n); var organizationConfig = new OrganizationConfig() { StartDepartment = 1, EndDepartment = n, NumberOfDepartments = n, NumberOfStamps = n, }; for (int i = 0; i < n; i++) { int j = (i + 1) % n; organizationConfig.Departments.Add ( departmentBuilder.GetDepartment(i + 1, j + 1, j + 1) ); } var organization = new Organization(organizationConfig); for (int i = 1; i <= n; i++) { var a = organization.GetResult(i); Assert.IsNotNull(a); Assert.IsNotNull(a.Checklists); Assert.IsTrue(a.Checklists.Count == 1); var uncheckedStamps = a.Checklists[0].GetAllUncheckedStamps(); if (i == n) { Assert.IsTrue(uncheckedStamps.Count == 1 && uncheckedStamps[0] == 1); } else { foreach (var stamp in uncheckedStamps) { Assert.IsTrue(stamp > i); } } Assert.IsTrue(a.Status == DepartmentStatus.Visited); } }
public void TaskRequests() { var depBuilder = new DepartmentBuilder(9, 3); var orgConfig = new OrganizationConfig() { StartDepartment = 1, EndDepartment = 9, NumberOfDepartments = 9, NumberOfStamps = 5, }; orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(2, 1, 2, 3, 3, 2, 6)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 4)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 5)); orgConfig.Departments.Add(depBuilder.GetDepartment(2, 1, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 7)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 8)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 1)); var organization = new Organization(orgConfig); var result = organization.GetResult(1); Assert.IsTrue(result.Status == DepartmentStatus.Visited); result = organization.GetResult(9); Assert.IsTrue(result.Status == DepartmentStatus.Inaccessible); List <Task <DepartmentResult> > tasks = new List <Task <DepartmentResult> >(); for (int i = 2; i <= 8; i++) { tasks.Add(new Task <DepartmentResult>(() => organization.GetResult(i))); tasks[i - 2].Start(); } Task.WaitAll(tasks.ToArray()); foreach (var task in tasks) { Assert.IsTrue(task.Result.Status == DepartmentStatus.Inaccessible); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var apiConfig = new ApiConfig { Url = "/api" }; services.AddSingleton(apiConfig); var orgConfig = new OrganizationConfig { Name = Configuration["OrganizationName"], }; services.AddSingleton(orgConfig); var appConfig = new AppConfig { ApiConfig = apiConfig, Organization = orgConfig, Customizable = Configuration["Customizable"].Equals("true", StringComparison.InvariantCultureIgnoreCase) }; services.AddSingleton(appConfig); services.AddSingleton <IFileProvider>(new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"))); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddAzureClients(builder => { builder.AddBlobServiceClient(Configuration["ConnectionStrings:eqarchives-string:blob"], preferMsi: true); builder.AddQueueServiceClient(Configuration["ConnectionStrings:eqarchives-string:queue"], preferMsi: true); }); }
public void Cycle8() { var depBuilder = new DepartmentBuilder(9, 3); var orgConfig = new OrganizationConfig() { StartDepartment = 1, EndDepartment = 9, NumberOfDepartments = 9, NumberOfStamps = 5, }; orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(2, 1, 2, 3, 3, 2, 6)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 4)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 5)); orgConfig.Departments.Add(depBuilder.GetDepartment(2, 1, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 7)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 8)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 2)); orgConfig.Departments.Add(depBuilder.GetDepartment(1, 2, 1)); var organization = new Organization(orgConfig); var result = organization.GetResult(1); Assert.IsTrue(result.Status == DepartmentStatus.Visited); result = organization.GetResult(9); Assert.IsTrue(result.Status == DepartmentStatus.Inaccessible); for (int i = 2; i <= 8; i++) { result = organization.GetResult(i); Assert.IsTrue(result.Status == DepartmentStatus.InCycle); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(x => x.EnableEndpointRouting = false); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var appInsightsConfig = new AppInsightsConfig { InstrumentationKey = Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"] }; services.AddSingleton(appInsightsConfig); services.AddApplicationInsightsTelemetry(appInsightsConfig.InstrumentationKey); var apiConfig = new ApiConfig { BaseUrl = Configuration["ApiUrl"], MrcApiUrl = Configuration["MrcApiUrl"], DocEntitiesApiUrl = Configuration["DocEntitiesApiUrl"], WidgetApiUrl = Configuration["WidgetApiUrl"] }; services.AddSingleton(apiConfig); var orgConfig = new OrganizationConfig { Logo = Configuration["OrganizationLogo"], Name = Configuration["OrganizationName"], Url = Configuration["OrganizationWebSiteUrl"], }; services.AddSingleton(orgConfig); var authorizationConfig = new AuthorizationConfig { AuthorityUri = Configuration["AuthorityUri"], ResourceUrl = Configuration["ResourceUrl"], RedirectUrl = Configuration["RedirectUrl"], PowerBIApiUrl = Configuration["PowerBIApiUrl"], ApplicationId = Configuration["ApplicationId"], LoggingRequestUrl = Configuration["LoggingRequestUrl"] }; #if DEBUG authorizationConfig.RedirectUrl = Configuration["RedirectUrlLocalhost"]; #endif services.AddSingleton(authorizationConfig); var appConfig = new AppConfig { ApiConfig = apiConfig, AppInsights = appInsightsConfig, Organization = orgConfig, Authorization = authorizationConfig, Customizable = Configuration["Customizable"].Equals("true", StringComparison.InvariantCultureIgnoreCase) }; services.AddSingleton(appConfig); services.AddSingleton <IFileProvider>(new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }