Ejemplo n.º 1
0
        public async Task Should_update_the_sandbox_db()
        {
            string uniqueId1 = Guid.NewGuid().ToString("N");
            string uniqueId2 = Guid.NewGuid().ToString("N");

            _httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", Guid.NewGuid().ToString("n"));

            var createResponse1 = await _httpClient.PostAsync(
                _uriHelper.BuildOdsUri("students", null),
                new StringContent(
                    ResourceHelper.CreateStudent(
                        uniqueId1,
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture),
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture)),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            createResponse1.EnsureSuccessStatusCode();

            var createResponse2 = await _httpClient.PostAsync(
                _uriHelper.BuildOdsUri("students", null),
                new StringContent(
                    ResourceHelper.CreateStudent(
                        uniqueId2,
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture),
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture)),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            createResponse2.EnsureSuccessStatusCode();

            int?exists1 = await StudentExistsAsync(uniqueId1);

            int?exists2 = await StudentExistsAsync(uniqueId2);

            exists1.ShouldNotBeNull();
            exists2.ShouldNotBeNull();
        }
        public async Task Should_update_specified_instance_db()
        {
            _httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", Guid.NewGuid().ToString("n"));

            var uniqueId2014Response = await _httpClient.PostAsync(
                _uriHelper.BuildIdentityUri("identities", 2014),
                new StringContent(
                    JsonConvert.SerializeObject(
                        new IdentityCreateRequest
            {
                BirthDate = new DateTime(1995, 2, 3),
                SexType = "Male"
            }),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            string uniqueId2014 = await ExtractIdFromHttpResponseAsync(uniqueId2014Response);

            var create2014Response = await _httpClient.PostAsync(
                _uriHelper.BuildOdsUri("students", 2014),
                new StringContent(
                    ResourceHelper.CreateStudent(
                        uniqueId2014,
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture),
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture)),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            create2014Response.EnsureSuccessStatusCode();

            var uniqueId2015Response = await _httpClient.PostAsync(
                _uriHelper.BuildIdentityUri("identities", 2014),
                new StringContent(
                    JsonConvert.SerializeObject(
                        new IdentityCreateRequest
            {
                BirthDate = new DateTime(1995, 2, 3),
                SexType = "Male"
            }),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            string uniqueId2015 = await ExtractIdFromHttpResponseAsync(uniqueId2014Response);

            var create2015Response = await _httpClient.PostAsync(
                _uriHelper.BuildOdsUri("students", 2015),
                new StringContent(
                    ResourceHelper.CreateStudent(
                        uniqueId2015,
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture),
                        DateTime.Now.Ticks.ToString(
                            CultureInfo.InvariantCulture)),
                    Encoding.UTF8,
                    "application/json"), _cancellationToken);

            create2015Response.EnsureSuccessStatusCode();

            int?exists2014 = await StudentExistsAsync(2014, uniqueId2014);

            int?notExists2014 = await StudentExistsAsync(2015, uniqueId2014);

            int?exists2015 = await StudentExistsAsync(2015, uniqueId2015);

            int?notExists2015 = await StudentExistsAsync(2014, uniqueId2015);

            exists2014.ShouldNotBeNull();
            notExists2014.ShouldBeNull();
            exists2015.ShouldNotBeNull();
            notExists2015.ShouldBeNull();
        }