Nfield.Services.Implementation.NfieldSurveyResponseCodesService.InitializeNfieldConnection C# (CSharp) Method

InitializeNfieldConnection() public method

INfieldConnectionClientObject.InitializeNfieldConnection
public InitializeNfieldConnection ( INfieldConnectionClient connection ) : void
connection INfieldConnectionClient
return void
        public void InitializeNfieldConnection(INfieldConnectionClient connection)
        {
            ConnectionClient = connection;
        }

Usage Example

        public void TestAddAsync_ValidSurveyResponseCode_CallsCorrectUrl()
        {
            // Arrange
            const string surveyId = "surveyId";
            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);

            var responseCodeToAdd = new SurveyResponseCode
            {
                ResponseCode = 15,
                Description = "Description",
                IsDefinite = true,
                AllowAppointment = false
            };
            mockedHttpClient.Setup(client => client.PostAsJsonAsync(It.IsAny<string>(), It.IsAny<SurveyResponseCode>()))
                .Returns(CreateTask(HttpStatusCode.OK,
                    new StringContent(JsonConvert.SerializeObject(new SurveyResponseCode()))));
            var target = new NfieldSurveyResponseCodesService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            // Act
            target.AddAsync(surveyId, responseCodeToAdd).Wait();

            // Assert
            mockedHttpClient.Verify( hc =>
                    hc.PostAsJsonAsync(It.Is<string>(url => url.EndsWith("Surveys/" + surveyId + "/ResponseCodes/")), responseCodeToAdd),
                    Times.Once());
        }
All Usage Examples Of Nfield.Services.Implementation.NfieldSurveyResponseCodesService::InitializeNfieldConnection