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

            Assert.Throws <ArgumentNullException>(() =>
                                                  UnwrapAggregateException(target.AddAsync(null, null)));
        }
        public void TestAddAsync_InvitationTemplateIsAdded_ReturnsInvitationTemplate()
        {
            const string surveyId = "TestSurveyId";

            var invitationTemplate = new InvitationTemplateModel
            {
                InvitationType = 1,
                Name           = "TestTemplate1",
                Subject        = "TestSubject1",
                Body           = "TestBody1"
            };
            var expected = new InvitationTemplateModel
            {
                Id             = 999,
                InvitationType = invitationTemplate.InvitationType,
                Name           = invitationTemplate.Name,
                Subject        = invitationTemplate.Subject,
                Body           = invitationTemplate.Body
            };

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

            mockedHttpClient
            .Setup(client => client.PostAsJsonAsync(new Uri(ServiceAddress, "Surveys/" + surveyId + "/InvitationTemplates/"), invitationTemplate))
            .Returns(CreateTask(HttpStatusCode.OK, content));

            var target = new NfieldSurveyInvitationTemplatesService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

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

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