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

RemoveAsync() public method

INfieldSurveyResponseCodesService.RemoveAsync
public RemoveAsync ( string surveyId, int code ) : System.Threading.Tasks.Task
surveyId string
code int
return System.Threading.Tasks.Task
        public Task RemoveAsync(string surveyId, int code)
        {
            if (string.IsNullOrEmpty(surveyId))
            {
                throw new ArgumentNullException("surveyId");
            }

            return
                Client.DeleteAsync(SurveyResponseCodeUrl(surveyId, code))
                      .FlattenExceptions();
        }

Usage Example

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

            mockedHttpClient.Setup(client => client.DeleteAsync(It.IsAny<string>()))
                .Returns(CreateTask(HttpStatusCode.OK));
            var target = new NfieldSurveyResponseCodesService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            // Act
            target.RemoveAsync(surveyId, code).Wait();

            // Assert
            mockedHttpClient.Verify(hc =>
                hc.DeleteAsync(It.Is<string>(
                        url => url.EndsWith(string.Format("Surveys/{0}/ResponseCodes/{1}", surveyId, code)))),
                Times.Once());
        }
All Usage Examples Of Nfield.Services.Implementation.NfieldSurveyResponseCodesService::RemoveAsync