Exemple #1
0
        public void TestAddOrUpdateAsync_ServerAcceptsSetting_ReturnsSetting()
        {
            var task = new BackgroundTask {
                Id = "TaskId"
            };
            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);
            var content = new StringContent(JsonConvert.SerializeObject(task));

            mockedHttpClient
            .Setup(client => client.GetAsync(new Uri(ServiceAddress, "Surveys/" + SurveyId + "/SampleData/" + FileName)))
            .Returns(CreateTask(HttpStatusCode.OK, content));

            var target = new NfieldSurveySampleDataService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.GetAsync(SurveyId, FileName).Result;

            Assert.Equal(task.Id, actual.Id);
        }
Exemple #2
0
        public void TestGetAsync_FileNameIsEmpty_Throws()
        {
            var target = new NfieldSurveySampleDataService();

            Assert.Throws <ArgumentException>(() => UnwrapAggregateException(target.GetAsync(SurveyId, "")));
        }
Exemple #3
0
        public void TestGetAsync_SurveyIdIsNull_Throws()
        {
            var target = new NfieldSurveySampleDataService();

            Assert.Throws <ArgumentNullException>(() => UnwrapAggregateException(target.GetAsync(null, FileName)));
        }