コード例 #1
0
        public async void UpdateComponentAsAdminDescriptionTooShortTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "X");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 "Description must be at least 2 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Description must be at least 2 characters", errorResponse.Message);
        }
コード例 #2
0
        public async void UpdateComponentAsAdminComponentNotFoundTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 404 not found
            Assert.Equal(404, result.StatusCode);
            Assert.Equal(ErrorCode.COMPONENT_NOT_FOUND, errorResponse.ErrorCodeEnum);
        }
コード例 #3
0
        public async void UpdateComponentAsAdminNameTooLongTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap gelegen naast de glijbaan in de skillgarden van Almere");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 401 UNAUTHORIZED
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Name can not be longer than 50 characters", errorResponse.Message);
        }
コード例 #4
0
        public async void UpdateComponentAsAdminTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Fiets parcour");
            formdata.Add("Description", "Race jij het snelst door de blauwe racebaan heen?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ComponentResponse resultComponent = (ComponentResponse)result.Value;

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
            Assert.Equal("Fiets parcour", resultComponent.Name);
        }
コード例 #5
0
        public async void UpdateComponentAsNonAdminTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Fiets parcour");
            formdata.Add("Description", "Race jij het snelst door de blauwe racebaan heen?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult resultUser = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.organiserClaim);

            ErrorResponse errorMessageUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorMessageOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageOrganiser.ErrorCodeEnum);
        }
コード例 #6
0
        public async void UpdateLocationAsAdminTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden IJmuiden");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            Location resultLocation = (Location)result.Value;

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
            // the email should be updated
            Assert.Equal("Skillgarden IJmuiden", resultLocation.Name);
        }
コード例 #7
0
        public async void UpdateLocationAsNonAdminTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(10));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden IJmuiden");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult resultUser = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 10, this.organiserClaim);

            ErrorResponse errorMessageUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorMessageOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageOrganiser.ErrorCodeEnum);
        }
コード例 #8
0
        public async void CreateNewLocationAsNonAdminTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("City", "Amsterdam Centrum");
            formdata.Add("Lat", "1.2345235");
            formdata.Add("Lng", "1.2134234");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult resultUser = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.organiserClaim);

            ErrorResponse errorResponseUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorResponseOrganiser = (ErrorResponse)resultOrganiser.Value;


            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseOrganiser.ErrorCodeEnum);
        }
コード例 #9
0
        public async void CreateNewComponentAsNonAdminTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult resultUser = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.organiserClaim);

            ErrorResponse errorResponseUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorResponseOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseOrganiser.ErrorCodeEnum);
        }
コード例 #10
0
        public async void CreateNewLocationAsAdminEmptyFormdataTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post, "empty");

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 INVALID_REQUEST_BODY
            Assert.Equal(400, result.StatusCode);
            Assert.Equal(ErrorCode.INVALID_REQUEST_BODY, errorResponse.ErrorCodeEnum);
        }
コード例 #11
0
        public async void CreateNewLocationAsAdminTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("City", "Amsterdam Centrum");
            formdata.Add("Lat", "1.2345235");
            formdata.Add("Lng", "1.2134234");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
        }
コード例 #12
0
        public async void CreateNewLocationAsAdminEmptyCityTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("Lat", "1.2134234");
            formdata.Add("Lng", "2.1657865");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 INVALID_REQUEST_BODY
            Assert.Equal(400, result.StatusCode);
            Assert.Equal(ErrorCode.INVALID_REQUEST_BODY, errorResponse.ErrorCodeEnum);
        }
コード例 #13
0
        public async void CreateNewLocationAsAdminCityTooLongTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Wales");
            formdata.Add("City", "Llanfair­pwllgwyngyll­gogery­chwyrn­drobwll­llan­tysilio­gogo­goch");
            formdata.Add("Lat", "1.2345235");
            formdata.Add("Lng", "1.2134234");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errorcode = "City can not be longer than 50 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("City can not be longer than 50 characters", errorResponse.Message);
        }
コード例 #14
0
        public async void CreateNewComponentAsAdminImageToBigTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post, "toBigImage");

            ObjectResult result = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.adminClaim);

            // status code should be 400
            Assert.Equal(400, result.StatusCode);
        }
コード例 #15
0
        public async void CreateNewLocationAsAdminLngNoDoubleTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("City", "Amsterdam");
            formdata.Add("Lat", "1.2134234");
            formdata.Add("Lng", "één punt twee drie negen vier");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errorcode = "Lat must be a double"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Lng must be a double", errorResponse.Message);
        }
コード例 #16
0
        public async void CreateNewLocationAsAdminCityTooShortTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Wales");
            formdata.Add("City", "X");
            formdata.Add("Lat", "1.2345235");
            formdata.Add("Lng", "1.2134234");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errorcode = "City must be at least 2 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("City must be at least 2 characters", errorResponse.Message);
        }
コード例 #17
0
        public async void CreateNewLocationAsAdminNameTooLongTest()
        {
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam op de grote buitenheuvel naast het postkantoor");
            formdata.Add("City", "Amsterdam Centrum");
            formdata.Add("Lat", "1.2345235");
            formdata.Add("Lng", "1.2134234");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.locationController.LocationCreate(requestmessage, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errormessage = "Name can not be longer than 50 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Name can not be longer than 50 characters", errorResponse.Message);
        }
コード例 #18
0
        public async void CreateNewComponentAsAdminNoExercisesTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post, "empty");

            ObjectResult result = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 INVALID_REQUEST_BODY
            Assert.Equal(400, result.StatusCode);
            Assert.Equal(ErrorCode.INVALID_REQUEST_BODY, errorResponse.ErrorCodeEnum);
        }
コード例 #19
0
        public async void CreateNewComponentAsAdminDescriptionTooLongTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. Stippentrap gelegen naast de glijbaan in de skillgarden van Almere. ");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 "Description can not be longer than 500 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Description can not be longer than 500 characters", errorResponse.Message);
        }
コード例 #20
0
        public async void CreateNewComponentAsAdminNameTooShortTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "X");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 "Name must be at least 2 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Name must be at least 2 characters", errorResponse.Message);
        }
コード例 #21
0
        public async void UpdateLocationAsAdminImageToBigTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("City", "Amsterdam");
            formdata.Add("Lat", "1.2343");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put, "toBigImage");

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400
            Assert.Equal(400, result.StatusCode);
        }
コード例 #22
0
        public async void UpdateLocationAsAdminLngNoDoubleTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam");
            formdata.Add("City", "Amsterdam");
            formdata.Add("Lat", "1.2343");
            formdata.Add("Lng", "één punt twee drie negen vier");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 INVALID_DOUBLEINPUT
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Lng must be a double", errorResponse.Message);
        }
コード例 #23
0
        public async void UpdateLocationAsAdminCityTooShortTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Wales");
            formdata.Add("City", "X");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errorcode = "City must be at least 2 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("City must be at least 2 characters", errorResponse.Message);
        }
コード例 #24
0
        public async void UpdateLocationAsAdminNameTooLongTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam op de grote buitenheuvel naast het postkantoor");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 and errormessag = "Name can not be longer than 50 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Name can not be longer than 50 characters", errorResponse.Message);
        }
コード例 #25
0
        public async void UpdateLocationAsAdminNotFoundTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden Amsterdam op de grote buitenheuvel naast het postkantoor");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 10, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 404 not found
            Assert.Equal(404, result.StatusCode);
            Assert.Equal(ErrorCode.LOCATION_NOT_FOUND, errorResponse.ErrorCodeEnum);
        }