Esempio n. 1
0
        private async Task SetIdAsync(string query)
        {
            var id = await StepsHelper.GetAsync <Guid>(
                _connectionStringProvider.Value.GetConnectionString(), query, _cancellationToken.Value);

            id.ShouldNotBeNull();

            _scenarioContext.Set(id, ScenarioContextKeys.CompositeSubjectId);
        }
Esempio n. 2
0
        private async Task SetStudentSchoolAssociationKeyInformationAsync(string query)
        {
            var dto = await StepsHelper.GetAsync <StudentSchoolKeyInformation>(
                _connectionStringProvider.Value.GetConnectionString(), query, _cancellationToken.Value);

            dto.ShouldNotBeNull();

            _scenarioContext.Set(dto.Id, ScenarioContextKeys.CompositeSubjectId);

            var keyValueByName = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase)
            {
                { "StudentUniqueId", dto.StudentUniqueId },
                { "SchoolId", dto.SchoolId },
                { "EntryDate", dto.EntryDate }
            };

            _scenarioContext.Set(keyValueByName, ScenarioContextKeys.CompositeSubjectKey);
        }
Esempio n. 3
0
        public async Task WhenAGETByIdRequestIsSubmittedToTheComposite(string compositeName)
        {
            // Default the category to test, if not specified
            var compositeCategoryName = "test";

            var httpClient = StepsHelper.GetHttpClient();

            var subjectId = _scenarioContext.Get <Guid>(ScenarioContextKeys.CompositeSubjectId);

            var pluralizedCompositeName = CompositeTermInflector.MakePlural(compositeName);

            string correlationId = Guid.NewGuid().ToString("n");

            SetCorrelationId(correlationId);

            string requestUrl = _edFiTestUriHelper.BuildCompositeUri(
                $"{compositeCategoryName}/{pluralizedCompositeName}/{subjectId:n}{StepsHelper.GetQueryString(correlationId)}");

            var response = await httpClient.GetAsync(requestUrl, _cancellationToken.Value);

            response.StatusCode.ShouldBe(HttpStatusCode.OK);
        }
Esempio n. 4
0
        public async Task WhenTheRequestIsSubmitted(string requestName)
        {
            string requestUrl = null;
            Guid   resourceId;

            switch (requestName)
            {
            case "School by Id":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901001 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/schools/{resourceId}";
                break;

            case "Schools by Local Education Agency (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/localEducationAgencies/{resourceId}/schools";
                break;

            case "Schools by Section (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Section",
                    new { SectionIdentifier = "25590100101Trad120ENG112011" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/sections/{resourceId}/schools";
                break;

            case "Schools by Staff (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Staff",
                    new { StaffUniqueId = "207268" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/staffs/{resourceId}/schools";
                break;

            case "Section by Id":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Section",
                    new { SectionIdentifier = "25590100101Trad120ENG112011" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/sections/{resourceId}";
                break;

            case "Sections by Local Education Agency (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/localEducationAgencies/{resourceId}/sections";
                break;

            case "Sections by School (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901001 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/schools/{resourceId}/sections";
                break;

            case "Sections by Staff (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Staff",
                    new { StaffUniqueId = "207268" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/staffs/{resourceId}/sections";
                break;

            case "Staff by Id":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Staff",
                    new { StaffUniqueId = "207268" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/staffs/{resourceId}";
                break;

            case "Staffs by Local Education Agency (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/localEducationAgencies/{resourceId}/staffs";
                break;

            case "Staffs by School (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901001 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/schools/{resourceId}/staffs";
                break;

            case "Staffs by Section (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Section",
                    new { SectionIdentifier = "25590100101Trad120ENG112011" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/sections/{resourceId}/staffs";
                break;

            case "Student by Id":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Student",
                    new { StudentUniqueId = "605042" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/students/{resourceId}";
                break;

            case "Students by Local Education Agency (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/localEducationAgencies/{resourceId}/students";
                break;

            case "Students by School (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "EducationOrganization",
                    new { EducationOrganizationId = 255901001 },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/schools/{resourceId}/students";
                break;

            case "Students by Section (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Section",
                    new { SectionIdentifier = "25590100101Trad120ENG112011" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/sections/{resourceId}/students";
                break;

            case "Students by Staff (Id)":

                resourceId = await StepsHelper.GetResourceIdAsync(
                    _connectionStringProvider.Value.GetConnectionString(),
                    "Staff",
                    new { StaffUniqueId = "207268" },
                    _cancellationToken.Value);

                requestUrl = $"enrollment/staffs/{resourceId}/students";
                break;

            default:

                throw new NotSupportedException(
                          string.Format("No request definition matched '{0}'.", requestName));
            }

            string correlationId = Guid.NewGuid().ToString("n");

            SetCorrelationId(correlationId);

            requestUrl += StepsHelper.GetQueryString(correlationId);

            string uri = _edFiTestUriHelper.BuildCompositeUri(requestUrl);

            string json = null;

            var httpClient = StepsHelper.GetHttpClient();
            var response   = await httpClient.GetAsync(uri, _cancellationToken.Value);

            response.StatusCode.ShouldBe(HttpStatusCode.OK);

            json = await response.Content.ReadAsStringAsync();

            var logger = LogManager.GetLogger(GetType());

            logger.Debug($"JSON response:{Environment.NewLine}{json}");
        }