public void TestUpdateAsync_InvitationTemplateIsNull_Throws()
        {
            var target = new NfieldSurveyInvitationTemplatesService();

            Assert.Throws <ArgumentNullException>(() =>
                                                  UnwrapAggregateException(target.UpdateAsync("a survey", null)));
        }
        public void TestUpdateAsync_SurveyIdIsWhitespace_Throws()
        {
            var target = new NfieldSurveyInvitationTemplatesService();

            Assert.Throws <ArgumentException>(() =>
                                              UnwrapAggregateException(target.UpdateAsync("  ", null)));
        }
        public void TestUpdateAsync_InvitationTemplateIsUpdated_ReturnsInvitationTemplate()
        {
            const string surveyId   = "TestSurveyId";
            const int    templateId = 42;

            var invitationTemplate = new InvitationTemplateModel
            {
                Id             = templateId,
                InvitationType = 1,
                Body           = "TestBody1"
            };
            var expected = new InvitationTemplateModel
            {
                Id             = templateId,
                InvitationType = invitationTemplate.InvitationType,
                Name           = "a Name",
                Subject        = "a Subject",
                Body           = invitationTemplate.Body
            };

            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);
            var content = new StringContent(JsonConvert.SerializeObject(expected));

            mockedHttpClient
            .Setup(client => client.PutAsJsonAsync(new Uri(ServiceAddress, "Surveys/" + surveyId + "/InvitationTemplates/" + templateId), It.Is <InvitationTemplateModel>(t => VerifyInvitationTemplate(t, invitationTemplate))))
            .Returns(CreateTask(HttpStatusCode.OK, content));

            var target = new NfieldSurveyInvitationTemplatesService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.UpdateAsync(surveyId, invitationTemplate).Result;

            Assert.Equal(expected, actual, new InvitationTemplateComparer());
        }