public AddAsync ( string surveyId, int languageId, Nfield.Models.Translation translation ) : Task |
||
surveyId | string | |
languageId | int | |
translation | Nfield.Models.Translation | |
Результат | Task |
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(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); }
public void TestAddAsync_SurveyIdIsNull_Throws() { var target = new NfieldTranslationsService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.AddAsync(null, 0, new Translation()))); }