コード例 #1
0
        public void TestAddImage_FilenameIsWhitespace_Throws()
        {
            var target = new NfieldSurveyInvitationImagesService();

            Assert.Throws <ArgumentException>(() =>
                                              UnwrapAggregateException(target.AddImageAsync("survey", "   ", new MemoryStream())));
        }
コード例 #2
0
        public void TestAddImage_ContentIsNull_Throws()
        {
            var target = new NfieldSurveyInvitationImagesService();

            Assert.Throws <ArgumentNullException>(() =>
                                                  UnwrapAggregateException(target.AddImageAsync("survey", "somefilename", null)));
        }
コード例 #3
0
        public void TestAddImage_SurveyIsEmpty_Throws()
        {
            var target = new NfieldSurveyInvitationImagesService();

            Assert.Throws <ArgumentException>(() =>
                                              UnwrapAggregateException(target.AddImageAsync(string.Empty, "somefilename", new MemoryStream())));
        }
コード例 #4
0
        public void TestAddImage_AllParamsOk_Successful()
        {
            const string surveyId = "surveyWithImages";
            const string filename = "imageForSurvey";

            var target     = new NfieldSurveyInvitationImagesService();
            var mockClient = InitMockClient(surveyId, filename);

            target.InitializeNfieldConnection(mockClient);

            AddInvitationImageResult actual;

            using (var stream = new MemoryStream(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }))
            {
                actual = target.AddImageAsync(surveyId, filename, stream).Result;
            }

            Assert.NotEmpty(actual.Link);
            Assert.True(actual.Link.Contains(surveyId));
            Assert.True(actual.Link.Contains(filename));
        }