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

InitializeNfieldConnection() public method

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

Usage Example

        public void TestGetSurveyPackageAsync_ReturnsSurveyPackage()
        {
            var expectedPackage = new SurveyPackage()
            {
                SurveyName = "SurveyName"
            };

            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient
                .Setup(client => client.GetAsync(ServiceAddress + "Surveys/" + SurveyId + "/Package/?type=" + InterviewPackageType.Live))
                .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedPackage))));

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

            var actual = target.GetSurveyPackageAsync(SurveyId, InterviewPackageType.Live).Result;

            Assert.Equal(expectedPackage.SurveyName, actual.SurveyName);
        }