Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public async Task DeleteProject_WhenProject_ShouldReturnOK()
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var project      = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            //Act
            var response = await ProjectService.DeleteProject(projectId);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Ejemplo n.º 4
0
        public async Task DeleteProject_WhenUnauthorized_ShouldReturnUnauthorized()
        {
            //Arrange
            ClientExtended.ClearAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var project      = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            //Act
            var response = await ProjectService.DeleteProject(projectId);

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

            var errorMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorMessage, ErrorMessage.FailedAuthentication);
        }
Ejemplo n.º 5
0
        public async Task AddSuite_WhenRequiredFieldHasIncorrectValue_ShouldReturnBadRequest(string serializedProject,
                                                                                             string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var project      = await ProjectService.AddProject(projectModel);

            var projectId  = ProjectSteps.GetProjectId(project);
            var suiteModel = NewtonsoftJsonSerializer.DefaultDeserialize <RequestSuiteModel>(serializedProject);

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

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

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, typeOfError);
        }
Ejemplo n.º 6
0
        public async Task DeleteProject_WhenDeleteProjectHasAlreadyBeenDeleted_ShouldReturnBadRequest()
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var project      = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);
            await ProjectService.DeleteProject(projectId);

            //Act
            var response = await ProjectService.DeleteProject(projectId);

            await ProjectService.GetProject(projectId);

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

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, ErrorMessage.IncorrectProjectId);
        }
Ejemplo n.º 7
0
        public async Task AddSuite_WhenProjectDoesNotExist_ShouldReturnBadRequest()
        {
            //Arrange
            SetAuthorization();

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

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            await ProjectService.DeleteProject(projectId);

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

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

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, ErrorMessage.IncorrectProjectId);
        }