Example #1
0
        public async void CreateFormShouldCreateNewEntityAndReturnCreated()
        {
            var allForms = await _fixture.GetHttpResult(UrlPath);

            var currentNumberOfForms =
                JsonConvert.DeserializeObject <List <FormListDto> >(allForms.Content.ReadAsStringAsync().Result).Count;

            _styles.Add(DataSeeder.StyleId1);
            _validations.Add(DataSeeder.ValidationId1);

            _fields.Append(new FieldCreateDto()
            {
                Name          = "TestField",
                ContentType   = "string",
                Label         = "label",
                Placeholder   = "placeholder",
                Value         = "value",
                Required      = true,
                OptionsJson   = "{\"id\":42 , \"name\":\"Rolando\"}",
                FieldType     = DataSeeder.FieldTypeId1,
                StyleIds      = _styles,
                ValidationIds = _validations
            });

            _fields.Append(new FieldCreateDto()
            {
                Name          = "FieldTest",
                ContentType   = "integer",
                Label         = "bezeichnung",
                Placeholder   = "platz",
                Value         = "Wert",
                Required      = false,
                OptionsJson   = "{\"id\":69 , \"name\":\"Messi\"}",
                FieldType     = DataSeeder.FieldTypeId1,
                ValidationIds = _validations
            });

            var newForm = new FormCreateDto()
            {
                Title            = "NewTest Form",
                IsPublic         = true,
                RestrictedAccess = false,
                FormHasField     = _fields
            };

            var serializedForm = JsonConvert.SerializeObject(newForm);

            var result = await _fixture.PostHttpResult(UrlPath, serializedForm);

            result.Should().NotBeNull();
            result.StatusCode.Should().Be(HttpStatusCode.Created);


            allForms = await _fixture.GetHttpResult(UrlPath);

            var newNumberOfForms = JsonConvert.DeserializeObject <List <FormListDto> >(allForms.Content.ReadAsStringAsync().Result).Count;

            newNumberOfForms.Should().Be(currentNumberOfForms + 1);
        }
Example #2
0
        public async void CreateRoleShouldCreateAndReturnANewRole()
        {
            var newRole = new RoleDto()
            {
                Name = "TestRolle"
            };

            var serializedRole = JsonConvert.SerializeObject(newRole);
            var result         = await _fixture.PostHttpResult(UrlPath, serializedRole);

            result.Should().NotBeNull();
            result.StatusCode.Should().Be(HttpStatusCode.Created);
        }
Example #3
0
        public async void AddRoleToUserShouldReturnOk()
        {
            var roleDto = new RoleDto()
            {
                Id   = _roleId1,
                Name = "Admin"
            };

            var serializedRoleDto = JsonConvert.SerializeObject(roleDto);
            var httpResponse      = await _fixture.PostHttpResult($"{UrlPath}{_userId3}/role", serializedRoleDto);

            httpResponse.Should().NotBeNull();
            httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Example #4
0
        public async void CreateConferenceShouldReturnOkAndTheNewObject()
        {
            var newConference = new ConferenceCreateDto()
            {
                Description        = "New Test Description For Conference",
                DateOfEvent        = DateTime.UtcNow,
                StartOfEvent       = "15:00",
                EndOfEvent         = "18:00",
                RoomOfEvent        = "A Room",
                NumberOfConference = 42
            };

            var serializedConference = JsonConvert.SerializeObject(newConference);
            var result = await _fixture.PostHttpResult(UrlPath, serializedConference);

            result.Should().NotBeNull();
            result.StatusCode.Should().Be(HttpStatusCode.Created);
        }
        public async void CreateCommentForApplicationShouldCreateAnewComment()
        {
            var applicationToTest = await _fixture.GetHttpResult(UrlPath + _applicationId);

            var currentNumberOfComments =
                JsonConvert.DeserializeObject <ApplicationDetailDto>(applicationToTest.Content.ReadAsStringAsync().Result)
                .Comments.Count();

            var newComment = new CommentCreateDto()
            {
                IsPrivate       = false,
                RequiresChanges = true,
                Message         = "Test Kommentar",
                // TODO Look at that again!!!
                UserId =
                    JsonConvert.DeserializeObject <ApplicationDetailDto>(applicationToTest.Content.ReadAsStringAsync().Result)
                    .User.Id
            };

            var serializedComment = JsonConvert.SerializeObject(newComment);
            var result            = await _fixture.PostHttpResult(UrlPath + _applicationId + "/comments/", serializedComment);

            result.Should().NotBeNull();
            result.StatusCode.Should().Be(HttpStatusCode.Created);

            applicationToTest = await _fixture.GetHttpResult(UrlPath + _applicationId);

            var newNumberOfComments = JsonConvert.DeserializeObject <ApplicationDetailDto>(applicationToTest.Content.ReadAsStringAsync().Result)
                                      .Comments.Count();

            newNumberOfComments.Should().Be(currentNumberOfComments + 1);
        }