Esempio n. 1
0
        public void TestDistributeAsync_ValidSurveyResponseCode_CallsCorrectUrl()
        {
            // Arrange
            const string surveyId = "surveyId";
            var          mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var          mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient.Setup(client => client.PostAsJsonAsync(It.IsAny <Uri>(), It.IsAny <SurveyInterviewerDistributeModel>()))
            .Returns(CreateTask(HttpStatusCode.OK));
            var target = new NfieldSurveyInterviewerWorkpackageDistributionService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            // Act
            var model = new SurveyInterviewerDistributeModel();

            target.DistributeAsync(surveyId, model).Wait();

            // Assert
            mockedHttpClient.Verify(hc =>
                                    hc.PostAsJsonAsync(
                                        It.Is <Uri>(url => url.AbsolutePath.EndsWith("Surveys/" + surveyId + "/Distribute/")),
                                        It.Is <SurveyInterviewerDistributeModel>(m => m == model)),
                                    Times.Once());
        }
Esempio n. 2
0
        public void TestDistributeAsync_ModelIsNull_Throws()
        {
            var target = new NfieldSurveyInterviewerWorkpackageDistributionService();

            Assert.Throws <ArgumentNullException>(
                () => UnwrapAggregateException(target.DistributeAsync("surveyId", null)));
        }