Implementation of INfieldSurveySettingsService
Inheritance: INfieldSurveySettingsService, INfieldConnectionClientObject
        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);
        }
 public void TestAddOrUpdateAsync_SurveyIdIsNull_Throws()
 {
     var target = new NfieldSurveySettingsService();
     Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.AddOrUpdateAsync(null, new SurveySetting())));
 }
 public void TestQueryAsync_SurveyIdIsEmpty_Throws()
 {
     var target = new NfieldSurveySettingsService();
     Assert.Throws<ArgumentException>(() => UnwrapAggregateException(target.QueryAsync("")));
 }