Beispiel #1
0
        public async Task UpdateSuite_WhenFieldMoreThanMaxLengthValue_ShouldReturnBadRequest(
            string serializedSuite, string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var suiteModel   = SuiteFactory.GetSuiteModel();

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            var suite = await SuiteService.AddSuite(projectId, suiteModel);

            var suiteId          = SuiteSteps.GetSuiteId(suite);
            var updateSuiteModel = NewtonsoftJsonSerializer.DefaultDeserialize <RequestSuiteModel>(serializedSuite);

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, updateSuiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var errorResponse = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorResponse, typeOfError);
        }
Beispiel #2
0
        public async Task UpdateSuite_ShouldReturnOK()
        {
            //Arrange
            SetAuthorization();

            var suiteModel   = SuiteFactory.GetSuiteModel();
            var projectModel = ProjectFactory.GetProjectModel();

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            var suite = await SuiteService.AddSuite(projectId, suiteModel);

            var suiteId          = SuiteSteps.GetSuiteId(suite);
            var updateSuiteModel = SuiteFactory.GetSuiteModel();

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, updateSuiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var responseSuite = response.GetResponseSuiteModel();

            SuiteAssert.ValidateSuiteResult(updateSuiteModel, responseSuite);
        }
Beispiel #3
0
        public async Task UpdateSuite_WhenNameHasIncorrectFormat_ShouldReturnBadRequest(string suiteId,
                                                                                        string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var suiteModel = SuiteFactory.GetSuiteModel();

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, suiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var errorResponse = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorResponse, typeOfError);
        }
Beispiel #4
0
        public async Task UpdateSuite_WhenUnauthorized_ShouldReturnUnauthorized()
        {
            //Arrange
            SetAuthorization();
            ClientExtended.ClearAuthorization();

            var       suiteModel = SuiteFactory.GetSuiteModel();
            const int suiteId    = 123;

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, suiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
            var errorResponse = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorResponse, ErrorMessage.FailedAuthentication);
        }