private void VerifyReturnsNoContent(int warId, VoteRequest voteRequest, System.Web.Http.IHttpActionResult result) { result.Should().BeOfType <StatusCodeResult>(); ((StatusCodeResult)result).StatusCode.Should().Be(HttpStatusCode.NoContent); voteRequest.UserIdentifier.Should().Be(_stubUser.Id); _stubVoteRepository.Verify(x => x.Add(warId, voteRequest), Times.Once); }
public void Get() { // Disponer jobtitlesController controller = new jobtitlesController(); // Actuar System.Web.Http.IHttpActionResult result = controller.Get(); JsonResult <List <JobTitle> > contentResult = result as JsonResult <List <JobTitle> >; // Declarar Assert.IsNotNull(contentResult.Content); }
public void GetIsNotNull() { // Arrange EmployeeController controller = new EmployeeController(); controller.objemployeebusiness = mockBusiness; // Act System.Web.Http.IHttpActionResult result = controller.Get() as System.Web.Http.IHttpActionResult; // Assert Assert.IsNotNull(result); }
public void Delete() { jobtitlesController controller = new jobtitlesController(); System.Web.Http.IHttpActionResult listJobTitles = controller.Get(); JsonResult <List <JobTitle> > contentList = listJobTitles as JsonResult <List <JobTitle> >; var firstElement = contentList.Content.OrderBy(x => x.JobTitleId).FirstOrDefault(); //If firsOrDefault is null there is not elements in the BBDD The test fail. Assert.IsNotNull(firstElement); var id = firstElement.JobTitleId; var result = controller.Get(id); JsonResult <JobTitle> contentResult = result as JsonResult <JobTitle>; Assert.IsNotNull(contentResult.Content); var retorn = controller.Delete(id); result = controller.Get(id); contentResult = result as JsonResult <JobTitle>; Assert.IsNull(contentResult.Content); }
public static HttpResponseMessage GetHttpResponseMessage(this System.Web.Http.IHttpActionResult message) { return(message.ExecuteAsync(CancellationToken.None).Result); }
private void CreateContactRecord(string projectName) { System.Web.Http.IHttpActionResult result = null; List <ContactAttribute> lstContactAttribute = null; ContactAttribute contactAttribute = null; ContactRecord contactRecord = null; Dictionary <string, string> scriptsParameter; DateTime timeUtc = DateTime.UtcNow; string previous = string.Empty; bool isLeadClientFound = false; try { contactRecord = new ContactRecord(); lstContactAttribute = new List <ContactAttribute>(); scriptsParameter = SessionManager.GetScriptParameter(HttpContext.Session); if (!string.IsNullOrEmpty(SessionManager.GetProgramParameterByKey("CallID", HttpContext.Session))) { contactRecord.ClientCallId = SessionManager.GetProgramParameterByKey("CallID", HttpContext.Session); } else { contactRecord.ClientCallId = "N/P"; } if (!string.IsNullOrEmpty(SessionManager.GetProgramParameterByKey("ANI", HttpContext.Session))) { contactRecord.ANI = SessionManager.GetProgramParameterByKey("ANI", HttpContext.Session); } else { contactRecord.ANI = "N/P"; } if (!string.IsNullOrEmpty(SessionManager.GetProgramParameterByKey("Previous", HttpContext.Session))) { previous = SessionManager.GetProgramParameterByKey("Previous", HttpContext.Session); } if (string.IsNullOrEmpty(SessionManager.GetUserId(HttpContext.Session)) && string.IsNullOrEmpty(SessionManager.GetClientId(HttpContext.Session))) { throw new Exception("User OR Client not found while creating contact record."); } try { TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings["timeZone"]); DateTime dateTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, timeZone); contactRecord.CallStartDateTime = dateTime; contactRecord.ModifiedDate = dateTime; contactRecord.ProjectName = projectName; contactRecord.CallState = "INPRC"; contactRecord.UserId = SessionManager.GetUserId(HttpContext.Session); contactRecord.ClientId = SessionManager.GetClientId(HttpContext.Session); if (!string.IsNullOrEmpty(SessionManager.ReturnParameter(HttpContext.Session, "LeadID"))) { contactRecord.LeadRecordId = SessionManager.ReturnParameter(HttpContext.Session, "LeadID"); } if (!string.IsNullOrEmpty(SessionManager.GetScriptURL(Session))) { contactRecord.URL = SessionManager.GetScriptURL(Session); } foreach (var item in scriptsParameter) { contactAttribute = new ContactAttribute(); contactAttribute.ContactAttributeName = item.Key; contactAttribute.ContactAttributeValue = item.Value; contactAttribute.CreatedDate = contactRecord.CallStartDateTime.Value; contactAttribute.ClientId = SessionManager.GetClientId(HttpContext.Session); lstContactAttribute.Add(contactAttribute); } contactRecord.ContactAttributes = lstContactAttribute; } catch { } ScreenViewer.API.ExternalData.ContactRecordController CRC = new API.ExternalData.ContactRecordController(); // Check LeadRecord and ClientCallId Exist then retrive client call id if (!string.IsNullOrEmpty(contactRecord.LeadRecordId) && !string.IsNullOrEmpty(contactRecord.ClientCallId)) { result = CRC.GetContactRecordByLeadClient(contactRecord.LeadRecordId, contactRecord.ClientCallId); if (result != null && result != result as System.Web.Http.Results.NotFoundResult) { isLeadClientFound = true; var response = result as OkNegotiatedContentResult <ContactRecord>; contactRecord = response.Content; SessionControl.SessionManager.StoreContactId(HttpContext.Session, contactRecord.ContactId); SessionManager.StoreProgramParameter("ClientCallId", contactRecord.ClientCallId, Session); } } if (!isLeadClientFound) { if (string.IsNullOrEmpty(previous)) { result = CRC.PostContactRecord(contactRecord); } else { result = CRC.GetContactRecordByContactId(Convert.ToInt32(previous)); } if (result != null && result != result as System.Web.Http.Results.NotFoundResult) { var response = result as OkNegotiatedContentResult <ContactRecord>; contactRecord = response.Content; SessionControl.SessionManager.StoreContactId(HttpContext.Session, contactRecord.ContactId); SessionManager.StoreProgramParameter("ClientCallId", contactRecord.ClientCallId, Session); } else { throw new Exception("Unable to create contact record."); } } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }