Exemple #1
0
        public void TestAddAsync_ServerAcceptsTranslation_ReturnsTranslation()
        {
            var translation = new Translation {
                Name = "X", Text = "X Translated"
            };
            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);
            var content = new StringContent(JsonConvert.SerializeObject(translation));

            mockedHttpClient
            .Setup(client => client.PostAsJsonAsync(new Uri(ServiceAddress, "Surveys/" + SurveyId + "/Languages/10/Translations"), translation))
            .Returns(CreateTask(HttpStatusCode.OK, content));

            var target = new NfieldTranslationsService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.AddAsync(SurveyId, LanguageId, translation).Result;

            Assert.Equal(translation.Name, actual.Name);
        }
Exemple #2
0
        public void TestAddAsync_SurveyIdIsEmpty_Throws()
        {
            var target = new NfieldTranslationsService();

            Assert.Throws <ArgumentException>(() => UnwrapAggregateException(target.AddAsync("", 0, new Translation())));
        }