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

RemoveAsync() public method

public RemoveAsync ( string surveyId, string fileName ) : System.Threading.Tasks.Task
surveyId string
fileName string
return System.Threading.Tasks.Task
        public Task RemoveAsync(string surveyId, string fileName)
        {
            if (string.IsNullOrEmpty(surveyId))
            {
                throw new ArgumentNullException("surveyId");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            return
                Client.DeleteAsync(MediaFilesApi(surveyId, fileName).AbsoluteUri)
                      .FlattenExceptions();
        }

Usage Example

コード例 #1
0
        public void TestRemoveAsync_Always_DoesNotThrow()
        {
            const string surveyId = "SurveyId";
            const string fileName = "MyFileName";

            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);
            mockedHttpClient
                .Setup(client => client.DeleteAsync(ServiceAddress + "Surveys/" + surveyId + "/MediaFiles/?fileName=" + fileName))
                .Returns(CreateTask(HttpStatusCode.OK));

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

            target.RemoveAsync(surveyId, fileName).Wait();
        }