InitializeNfieldConnection() public method

public InitializeNfieldConnection ( INfieldConnectionClient connection ) : void
connection INfieldConnectionClient
return void
        public void TestAddOrUpdateAsync_ServerAcceptsSetting_ReturnsSetting()
        {
            var setting = new SurveySetting { Name = "Setting X" };
            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);
            var content = new StringContent(JsonConvert.SerializeObject(setting));
            mockedHttpClient
                .Setup(client => client.PostAsJsonAsync(ServiceAddress + "Surveys/" + SurveyId + "/Settings", setting))
                .Returns(CreateTask(HttpStatusCode.OK, content));

            var target = new NfieldSurveySettingsService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.AddOrUpdateAsync(SurveyId, setting).Result;

            Assert.Equal(setting.Name, actual.Name);
        }
        public void TestQueryAsync_ServerReturnsQuery_ReturnsListWithSettings()
        {
            var expectedSettings = new SurveySetting[]
            { new SurveySetting{ Name = "X", Value = "X Value" },
              new SurveySetting{ Name = "Y", Value = "Y Value" }
            };
            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);
            mockedHttpClient
                .Setup(client => client.GetAsync(ServiceAddress + "Surveys/" + SurveyId + "/Settings"))
                .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedSettings))));

            var target = new NfieldSurveySettingsService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actualSettings = target.QueryAsync(SurveyId).Result.ToArray(); ;
            Assert.Equal(expectedSettings[0].Name, actualSettings[0].Name);
            Assert.Equal(expectedSettings[1].Name, actualSettings[1].Name);
            Assert.Equal(2, actualSettings.Length);
        }