public void TestQueryAsync_ServerReturnsQuery_ReturnsListWithPublicIds() { var expectedPublicIds = new [] { new SurveyPublicId { LinkType = "X Type", Active = false, Url = "X Url" }, new SurveyPublicId { LinkType = "Y Type", Active = true, Url = "Y Url" } }; var mockedNfieldConnection = new Mock<INfieldConnectionClient>(); var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection); mockedHttpClient .Setup(client => client.GetAsync(ServiceAddress + "Surveys/" + SurveyId + "/PublicIds")) .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedPublicIds)))); var target = new NfieldSurveyPublicIdsService(); target.InitializeNfieldConnection(mockedNfieldConnection.Object); var actualPublicIds = target.QueryAsync(SurveyId).Result.ToArray(); ; Assert.Equal(expectedPublicIds[0].LinkType, actualPublicIds[0].LinkType); Assert.Equal(expectedPublicIds[0].Active, actualPublicIds[0].Active); Assert.Equal(expectedPublicIds[0].Url, actualPublicIds[0].Url); Assert.Equal(expectedPublicIds[1].LinkType, actualPublicIds[1].LinkType); Assert.Equal(expectedPublicIds[1].Active, actualPublicIds[1].Active); Assert.Equal(expectedPublicIds[1].Url, actualPublicIds[1].Url); Assert.Equal(2, actualPublicIds.Length); }
public void TestQueryAsync_SurveyIdIsNull_Throws() { var target = new NfieldSurveyPublicIdsService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.QueryAsync(null))); }