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); }
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); }
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); }
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); }
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); }
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); }
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); }