public static void SeedDefaultArticles(CustomWebApplicationFactory <DFC.App.JobCategories.Startup> factory)
        {
            const string url = "/pages";
            var          contentPageModels = new List <JobCategory>()
            {
                new JobCategory()
                {
                    DocumentId    = Guid.Parse("5DDE75FF-8B32-4746-9712-2672E5C540DB"),
                    CanonicalName = "care-worker",
                    Description   = "care worker description",
                },
                new JobCategory()
                {
                    DocumentId    = Guid.Parse("5DDE75FF-8B31-4746-9712-2672E5C540DB"),
                    CanonicalName = "refuse-worker",
                    Description   = "collects refuse",
                },
                new JobCategory()
                {
                    DocumentId    = Guid.Parse("5DDE75FF-8B32-4746-9212-2672E5C540DB"),
                    CanonicalName = "aid-worker",
                    Description   = "aid worker description",
                },
            };

            var client = factory?.CreateClient();

            client?.DefaultRequestHeaders.Accept.Clear();

            contentPageModels.ForEach(f => client.PostAsync(url, f, new JsonMediaTypeFormatter()).GetAwaiter().GetResult());
        }
        public static void SeedDefaultArticles(CustomWebApplicationFactory <DFC.App.ContactUs.Startup> factory)
        {
            var eventGridEventDataItems = new List <EventGridEventData>()
            {
                new EventGridEventData()
                {
                    ItemId      = "3627EDA0-A5EF-405F-BD91-349FCAD91105",
                    DisplayText = "Send us a letter",
                },
                new EventGridEventData()
                {
                    ItemId      = "46CB08FD-613E-4E72-8C08-39A8B256844E",
                    DisplayText = "Thank you for contacting us",
                },
                new EventGridEventData()
                {
                    ItemId      = "EDFC8852-9820-4F29-B006-9FBD46CAB646",
                    DisplayText = "test-grid-4-x-3",
                },
            };

            var client = factory?.CreateClient();

            client !.DefaultRequestHeaders.Accept.Clear();

            foreach (var eventGridEventData in eventGridEventDataItems)
            {
                eventGridEventData.Api = "https://localhost:44354/home/item/contact-us/" + eventGridEventData.ItemId;
                var eventGridEvents = BuildValidEventGridEvent(EventTypePublished, eventGridEventData);
                var uri             = new Uri("/" + WebhookApiUrl, UriKind.Relative);
                var result          = client.PostAsync(uri, eventGridEvents, new JsonMediaTypeFormatter()).GetAwaiter().GetResult();
            }
        }
        public async Task RemoveData(CustomWebApplicationFactory <Startup> factory)
        {
            var models = CreateModels();

            var client = factory?.CreateClient();

            client.DefaultRequestHeaders.Accept.Clear();

            foreach (var model in models)
            {
                var url = string.Concat("/", Segment, "/", model.DocumentId);
                await client.DeleteAsync(url).ConfigureAwait(false);
            }
        }
        public async Task AddData(CustomWebApplicationFactory <Startup> factory)
        {
            var url    = $"/{Segment}";
            var models = CreateModels();

            var client = factory?.CreateClient();

            client.DefaultRequestHeaders.Accept.Clear();

            foreach (var model in models)
            {
                await client.PostAsync(url, model, new JsonMediaTypeFormatter()).ConfigureAwait(false);
            }
        }
 public HangfireStorageStartupTest(CustomWebApplicationFactory <StartupTest> factory)
 {
     _factory = factory;
     _client  = factory.CreateClient();
 }
 public Delete(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
 public MetaControllerInfo(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
Exemplo n.º 8
0
 public RuleControllerIntegrationTests(CustomWebApplicationFactory <Startup> factory)
 {
     _httpClient = factory.CreateClient();
 }
 public TradeApiTests(CustomWebApplicationFactory factory)
 {
     _factory = factory;
     _client  = _factory.CreateClient();
 }
Exemplo n.º 10
0
 public Get(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
     _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Test");
 }
Exemplo n.º 11
0
 public ProjectList(CustomWebApplicationFactory <WebMarker> factory)
 {
     _client = factory.CreateClient();
 }
 public IT_RecipeControllerTests(CustomWebApplicationFactory <Startup> factory)
 {
     factory.ClientOptions.BaseAddress = new Uri(uri);
     _httpClient = factory.CreateClient();
     _factory    = factory;
 }
Exemplo n.º 13
0
 public Schedule(CustomWebApplicationFactory <Startup> factory)
 {
     _client   = factory.CreateClient();
     _jobMaker = new TestJobMaker();
 }
Exemplo n.º 14
0
 public void Setup()
 {
     _factory = new CustomWebApplicationFactory <Startup>();
     _client  = _factory.CreateClient();
 }
Exemplo n.º 15
0
        public async Task Test_All()
        {
            var client = _factory.CreateClient();

            // gets all
            {
                var response = await client.GetAsync("Books/");

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                Assert.Contains("Title", result);
            }

            // create form
            var    bookId = 0;
            string authToken;
            KeyValuePair <string, string> cookie;
            {
                var response = await client.GetAsync("/Books/Create");

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                Assert.Contains("Create Book", result);
                authToken = Testing.ExtractAntiForgeryToken(result);
                cookie    = Testing.ExtractCookie(response);
            }

            // create
            {
                var data = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("__RequestVerificationToken", authToken),
                    new KeyValuePair <string, string>("Title", "a11"),
                    new KeyValuePair <string, string>("Descirption", "desc1")
                };
                // var rs = await ParseResponse((await client.GetAsync("api/Books")));

                var request = new HttpRequestMessage(HttpMethod.Post, "/Books/Create")
                {
                    Content = new FormUrlEncodedContent(data)
                };
                request.Headers.Add("Cookie", $"{cookie.Key}={cookie.Value}");
                var response = await client.SendAsync(request);

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                // var rs2 = await ParseResponse((await client.GetAsync("api/Books")));

                Assert.Contains("created", result);
                var pattern = new Regex(@"Books #(?<bookId>\d+) ");
                var match   = pattern.Match(result);
                bookId = int.Parse(match.Groups["bookId"].Value);
            }

            // get one
            {
                var response = await client.GetAsync($"/Books/{bookId}");

                var result = await ParseResponse(response);

                Assert.Contains($"Books #{bookId}", result);
            }

            // edit form
            {
                var response = await client.GetAsync($"/Books/{bookId}/Edit");

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                Assert.Contains("Edit Book", result);
                authToken = Testing.ExtractAntiForgeryToken(result);
                cookie    = Testing.ExtractCookie(response);
            }

            // update
            {
                var data = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("__RequestVerificationToken", authToken),
                    new KeyValuePair <string, string>("Title", "a1"),
                    new KeyValuePair <string, string>("Descirption", "desc2")
                };

                var request = new HttpRequestMessage(HttpMethod.Post, $"/Books/{bookId}/Edit")
                {
                    Content = new FormUrlEncodedContent(data)
                };
                request.Headers.Add("Cookie", $"{cookie.Key}={cookie.Value}");
                var response = await client.SendAsync(request);

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                Assert.Contains("updated", result);
            }

            // delete
            {
                var response = await client.PostAsync($"/Books/{bookId}/Delete", null);

                response.EnsureSuccessStatusCode();
                var result = await ParseResponse(response);

                Assert.Contains("deleted", result);
            }
        }
Exemplo n.º 16
0
        public InquiryMineTests(CustomWebApplicationFactory <JinCreek.Server.Admin.Startup> factory)
        {
            _client  = factory.CreateClient();
            _context = factory.Services.GetService <IServiceScopeFactory>().CreateScope().ServiceProvider.GetService <MainDbContext>();

            Utils.RemoveAllEntities(_context);

            _context.Add(_org1    = Utils.CreateOrganization(code: 1, name: "org1"));
            _context.Add(_org2    = Utils.CreateOrganization(code: 2, name: "org2"));
            _context.Add(_domain1 = new Domain {
                Id = Guid.NewGuid(), Name = "domain01", OrganizationCode = _org1.Code
            });
            _context.Add(_domain2 = new Domain {
                Id = Guid.NewGuid(), Name = "domain02", OrganizationCode = _org2.Code
            });
            _context.Add(_userGroup1 = new UserGroup {
                Id = Guid.NewGuid(), Name = "userGroup1", DomainId = _domain1.Id
            });
            _context.Add(_userGroup2 = new UserGroup {
                Id = Guid.NewGuid(), Name = "userGroup2", DomainId = _domain2.Id
            });
            _context.Add(_user0 = new SuperAdmin {
                AccountName = "user0", Password = Utils.HashPassword("user0")
            });                                                                                                      // スーパー管理者
            _context.Add(_user1 = new UserAdmin {
                AccountName = "user1", Password = Utils.HashPassword("user1"), DomainId = _domain1.Id
            });                                                                                                                             // ユーザー管理者
            _context.Add(_user2 = new GeneralUser()
            {
                AccountName = "user2", DomainId = _domain2.Id
            });
            _context.Add(_simGroup1 = new SimGroup
            {
                Id                      = Guid.NewGuid(),
                Name                    = "simGroup1",
                Organization            = _org1,
                Apn                     = "apn",
                AuthenticationServerIp  = "AuthServerIpAddress",
                IsolatedNw1IpPool       = "Nw1IpAddressPool",
                IsolatedNw1SecondaryDns = "Nw1SecondaryDns",
                IsolatedNw1IpRange      = "Nw1IpAddressRange",
                IsolatedNw1PrimaryDns   = "Nw1PrimaryDns",
                NasIp                   = "NasIpAddress",
                UserNameSuffix          = "UserNameSuffix",
                PrimaryDns              = "PrimaryDns",
                SecondaryDns            = "SecondaryDns"
            });
            _context.Add(_simGroup2 = new SimGroup {
                Id = Guid.NewGuid(), Name = "simGroup2", OrganizationCode = _org2.Code
            });
            _context.Add(_sim1 = new Sim {
                SimGroup = _simGroup1, Msisdn = "msisdn01", Imsi = "imsi01", IccId = "iccid01", UserName = "******", Password = "******"
            });
            _context.Add(_sim2 = new Sim {
                SimGroup = _simGroup1, Msisdn = "msisdn01", Imsi = "imsi01", IccId = "iccid01", UserName = "******", Password = "******"
            });                                                                                                                                                         //他組織
            _context.Add(_deviceGroup1 = new DeviceGroup {
                Id = Guid.NewGuid(), DomainId = _domain1.Id, Name = "deviceGroup1"
            });
            _context.Add(_device1 = new Device {
                Id = Guid.NewGuid(), DomainId = _domain1.Id, Name = "device1", ManagedNumber = "2", UseTpm = true, WindowsSignInListCacheDays = 1
            });
            _context.Add(_device1 = new Device {
                Id = Guid.NewGuid(), DomainId = _domain2.Id, Name = "device2", ManagedNumber = "2", UseTpm = true, WindowsSignInListCacheDays = 1
            });                                                                                                                                                                       //他組織
            _context.Add(_simDevice1 = new SimAndDevice {
                SimId = _sim1.Id, DeviceId = _device1.Id
            });
            _context.Add(_simDevice2 = new SimAndDevice {
                SimId = _sim2.Id, DeviceId = _device1.Id
            });                                                                                        // sim 他組織
            //_context.Add(_simDevice3 = new SimAndDevice { SimId = _sim1.Id, DeviceId = _device2.Id }); // 端末 他組織
            _context.Add(_multiFactor2 = new MultiFactor {
                Id = Guid.NewGuid(), SimAndDeviceId = _simDevice1.Id, EndUserId = _user2.Id
            });                                                                                                                            //User他組織
            _context.SaveChanges();
        }
 public void OneTimeSetup()
 {
     _factory = new();
     _factory.ClientOptions.BaseAddress = new Uri("http://localhost/api/products/");
     _client = _factory.CreateClient();
 }
 public UpdatesControllerIntegrationTests(CustomWebApplicationFactory <ProjectSeed> factory)
 {
     _client = factory.CreateClient();
 }
Exemplo n.º 19
0
 public BaseServiceTest(CustomWebApplicationFactory <Startup> factory)
 {
     Client = factory.CreateClient();
 }
Exemplo n.º 20
0
 public OrderTests(CustomWebApplicationFactory <Startup> factory)
 {
     _client = new OrderServiceClient(factory.CreateClient());
 }
Exemplo n.º 21
0
 public GetListTest(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
 public ResourcesControllerIntergationTests(CustomWebApplicationFactory <Startup> factory)
 {
     httpClient = factory.CreateClient();
 }
 public ApiToDoItemsControllerList(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
Exemplo n.º 24
0
 public QuestionsPageGet(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
 public DoctorsList(CustomWebApplicationFactory <Startup> factory, ITestOutputHelper outputHelper)
 {
     _client       = factory.CreateClient();
     _outputHelper = outputHelper;
 }
 private HttpClient GetClient()
 {
     return(factory.CreateClient(new WebApplicationFactoryClientOptions {
         AllowAutoRedirect = false
     }));
 }
Exemplo n.º 27
0
 public AuthControllerTests(CustomWebApplicationFactory <Startup> factory)
 {
     this._client = factory.CreateClient();
 }
Exemplo n.º 28
0
        public void BeforeScenario()
        {
            lock (_obj)
            {
                Evt.WaitOne();
                if (_factory == null)
                {
                    _scenarioContextProvider = new ScenarioContextProvider();
                    _factory = new CustomWebApplicationFactory <FakeStartup>(c =>
                    {
                        c.AddSingleton(_scenarioContextProvider);
                        c.AddSingleton <CaseManagement.Common.Factories.IHttpClientFactory>(new FakeHttpClientFactory(() => _factory.CreateClient()));
                    });
                    _client = _factory.CreateClient();
                }

                _scenarioContextProvider.SetContext(_scenarioContext);
            }
        }
Exemplo n.º 29
0
 public CreateEndpoint(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }
Exemplo n.º 30
0
 public IntegrationTest1(CustomWebApplicationFactory <Startup> factory)
 {
     _client = factory.CreateClient();
 }