public async Task When_GetAllSkillsForOccupation_Then_ShouldReturnSkillsList(string url, string apiKey) { // ARRANGE const string skillsJson = "{skills:[" + "{\"type\": \"competency\",\"relationshipType\": \"essential\",\"skill\": \"collect biological data\",\"alternativeLabels\": [\"biological data analysing\", \"analysing biological records\"],\"uri\": \"aaa\"}," + "{\"type\": \"competency\",\"relationshipType\": \"essential\",\"skill\": \"collect biological info\",\"alternativeLabels\": [\"biological data analysing\", \"analysing biological records\"],\"uri\": \"aaa\"}," + "{\"type\": \"competency\",\"relationshipType\": \"optional\",\"skill\": \"collect samples\",\"alternativeLabels\": [\"biological data collection\", \"analysing biological records\"],\"uri\": \"aaa\"}]}"; var handlerMock = MockHelpers.GetMockMessageHandler(skillsJson, HttpStatusCode.OK); var restClient = new RestClient(handlerMock.Object); var subjectUnderTest = new ServiceTaxonomyRepository(restClient); var vm = new SelectSkillsCompositeViewModel(); // ACTs var result = await subjectUnderTest.GetAllSkillsForOccupation <Skill[]>(url, apiKey, "http://data.europa.eu/esco/occupation/114e1eff-215e-47df-8e10-45a5b72f8197"); vm.Skills = result.ToList(); // ASSERT result.Should().NotBeNull(); result.Length.Should().Be(3); handlerMock.Protected().Verify( "SendAsync", Times.Once(), // we expected a single external request ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Post ), ItExpr.IsAny <CancellationToken>() ); }
public void When_OccupationSet_Then_ToReturnOccupation() { // Arrange. var vm = new SelectSkillsCompositeViewModel() { Occupation = "Tester" }; // Assert. vm.Occupation.Should().Be("Tester"); }