public void GetOpportunityByName_Ok() { var jsonDataTable = @"[ { 'OpportunityId': '1', 'OpportunityName': 'Squad Care', 'OpportunityRequirements': '.NET Core', 'DesirableRequirements': 'Conhecimento em Kafka', 'DateRegister': '2021-05-05T00:00:00', 'ClosingDate': '2021-05-05T00:00:00', 'CancellationDate': '2021-05-05T00:00:00', 'OpportunityStatus': true, 'CareerId': '1', 'ServiceId': '1', 'ProfessionalLevelId': '1', 'OpportunityTypeId': '1', } ]"; var vacationLeader = "Thomas Anjos"; var listOpportunities = JsonConvert.DeserializeObject <List <Opportunity> >(jsonDataTable); _opportunityService.Setup(x => x.GetAllOpportunities()).Returns(listOpportunities); var control = new OpportunityController(_opportunityService.Object); var result = control.GetOpportunityByName(vacationLeader); var okResult = result as OkObjectResult; Assert.IsNotNull(result); Assert.AreEqual(200, okResult.StatusCode); }
public void GetOpportunityByName_Ok() { var jsonOpportunity = @" { 'OpportunityId': '1', 'OpportunityName': 'Squad Care', 'OpportunityRequirements': '.NET Core', 'DesirableRequirements': 'Conhecimento em Kafka', 'DateRegister': '2021-05-05T00:00:00', 'ClosingDate': '2021-05-05T00:00:00', 'CancellationDate': '2021-05-05T00:00:00', 'OpportunityStatus': false, 'CareerId': '1', 'ServiceId': '1', 'ProfessionalLevelId': '1', 'OpportunityTypeId': '1', }"; var opportunity = JsonConvert.DeserializeObject <Opportunity>(jsonOpportunity); var opportunityName = "Squad Care"; _opportunityServiceMock.Setup(x => x.GetOpportunityByName(opportunityName)).Returns(opportunity); var control = new OpportunityController(_opportunityServiceMock.Object); var result = control.GetOpportunityByName(opportunityName); var okResult = result as OkObjectResult; Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); }
public void GetOpportunityByName_BadRequest() { var opportunityName = ""; var control = new OpportunityController(_opportunityService.Object); var result = control.GetOpportunityByName(opportunityName); var badRequestResult = result as BadRequestResult; Assert.AreEqual(400, badRequestResult.StatusCode); }