public void TestQueryAsync_ServerReturnsQuery_ReturnsListWithLanguages() { var expectedLanguages = new Language[] { new Language{Id = 11, Name = "X"}, new Language{Id = 12, Name = "Y"} }; var mockedNfieldConnection = new Mock<INfieldConnectionClient>(); var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection); mockedHttpClient .Setup(client => client.GetAsync(ServiceAddress + "Surveys/" + SurveyId + "/Languages")) .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedLanguages)))); var target = new NfieldLanguagesService(); target.InitializeNfieldConnection(mockedNfieldConnection.Object); var actualLanguages = target.QueryAsync(SurveyId).Result; Assert.Equal(expectedLanguages[0].Id, actualLanguages.ToArray()[0].Id); Assert.Equal(expectedLanguages[1].Id, actualLanguages.ToArray()[1].Id); Assert.Equal(2, actualLanguages.Count()); }
public void TestQueryAsync_SurveyIdIsNull_Throws() { var target = new NfieldLanguagesService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.QueryAsync(null))); }