public void UpdateTag_DuplicitName_ThrowsException() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; PostAndMarkForDelete(tagPostModel); tagPostModel = new TagPostModel { Name = Tag2Color, Color = Tag2Color }; var id = PostAndMarkForDelete(tagPostModel); var tagPatchModel = new TagPatchModel { Id = id, Name = Tag1Name }; // Act var result = TagClient.Update(tagPatchModel); // Assert Assert.False(result.IsSuccess); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
private int PostAndMarkForDelete(TagPostModel tagPostModel) { var tagGetModel = TagClient.Post(tagPostModel).AssertResult(); MarkForDelete(tagGetModel.Id); return(tagGetModel.Id); }
public void TearDown() { foreach (var id in _tagIdsToDelete) { TagClient.Delete(id); } }
public void Get_WithFilter_ReturnsFilteredList() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; PostAndMarkForDelete(tagPostModel); tagPostModel = new TagPostModel { Name = Tag2Name, Color = Tag2Color }; var id = PostAndMarkForDelete(tagPostModel); // Act var data = TagClient.List() .Filter(t => t.Name.IsEqual(Tag2Name)) .Get().AssertResult(); // Assert Assert.AreEqual(1, data.TotalItems); Assert.AreEqual(1, data.TotalPages); Assert.NotNull(data.Items); Assert.NotZero(data.Items.Count()); var tag = data.Items.First(t => t.Id == id); Assert.AreEqual(id, tag.Id); Assert.AreEqual(tagPostModel.Color, tag.Color); Assert.AreEqual(tagPostModel.Name, tag.Name); }
public async Task GetAsync() { var apiConnection = Substitute.For <IApiConnection>(); var client = new TagClient(apiConnection); await client.GetAsync(); await apiConnection.Received().ExecutePaginationGetAsync <TagArticle>("tags", Arg.Any <PageQueryOption>()); }
public async Task DeleteTagAsync_NonExistingId_Fails() { // Arrange var tagId = 0; // Act var result = await TagClient.DeleteAsync(tagId); // Assert Assert.False(result.IsSuccess); Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode); }
public void DeleteTag_NonExistingId_Fails() { // Arrange var tagId = 0; // Act var result = TagClient.Delete(tagId); // Assert Assert.False(result.IsSuccess); Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode); }
public void UpdateTag_NonExistingId_ThrowsException() { // Arrange var tagId = 0; var tagPatchModel = new TagPatchModel { Id = tagId }; // Act var result = TagClient.Update(tagPatchModel); // Assert Assert.False(result.IsSuccess); Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode); }
public async Task DeleteTagAsync_SuccessfullyDeleted() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; var id = PostAndMarkForDelete(tagPostModel); // Act var result = (await TagClient.DeleteAsync(id)).AssertResult(); // Assert Assert.True(result); }
public void DeleteTag_SuccessfullyDeleted() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; var id = PostAndMarkForDelete(tagPostModel); // Act var result = TagClient.Delete(id).AssertResult(); // Assert Assert.True(result); }
public void AddTag_SuccessfullyAdded() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; // Act var tagGetModel = TagClient.Post(tagPostModel).AssertResult(); MarkForDelete(tagGetModel.Id); // Assert Assert.NotZero(tagGetModel.Id); Assert.AreEqual(Lowercase(tagPostModel.Color), tagGetModel.Color); Assert.AreEqual(tagPostModel.Name, tagGetModel.Name); }
public void AddTag_DuplicitName_Fails() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; PostAndMarkForDelete(tagPostModel); tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag2Color }; // Act var result = TagClient.Post(tagPostModel); // Assert Assert.False(result.IsSuccess); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
public async Task UpdateTagAsync_ColorOnlyUpdate_SuccessfullyUpdated() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; var id = PostAndMarkForDelete(tagPostModel); var tagPatchModel = new TagPatchModel { Id = id, Color = Tag2Color }; // Act var tagGetModel = (await TagClient.UpdateAsync(tagPatchModel)).AssertResult(); // Assert Assert.NotZero(tagGetModel.Id); Assert.AreEqual(Lowercase(tagPatchModel.Color), tagGetModel.Color); Assert.AreEqual(tagPostModel.Name, tagGetModel.Name); }
/// <summary> /// API client /// </summary> /// <remarks> /// See the <a href="https://docs.dev.to/api/#section/Authentication/api_key">Authentication</a> for more information /// </remarks> /// <param name="apiUrl">API connection url</param> /// <param name="token">API key</param> public DevToClient(string apiUrl, string token) { var restClient = new RestClient(apiUrl); restClient.AddDefaultHeader("api-key", token); restClient.AddDefaultHeader("User-Agent", "DevToAPI-client-dotnet"); var apiConnection = new ApiConnection(restClient); AdminConfigurations = new AdminConfigurationClient(apiConnection); Articles = new ArticleClient(apiConnection); Comments = new CommentClient(apiConnection); Followers = new FollowerClient(apiConnection); Follows = new FollowClient(apiConnection); Listings = new ListingClient(apiConnection); Organizations = new OrganizationClient(apiConnection); PodcastEpisodes = new PodcastEpisodeClient(apiConnection); ReadingLists = new ReadingListClient(apiConnection); Tags = new TagClient(apiConnection); Users = new UserClient(apiConnection); Videos = new VideoClient(apiConnection); Webhooks = new WebhookClient(apiConnection); ProfileImages = new ProfileImageClient(apiConnection); }
public void UpdateTag_NameOnlyUpdate_Name_SuccessfullyUpdated() { // Arrange var tagPostModel = new TagPostModel { Name = Tag1Name, Color = Tag1Color }; var id = PostAndMarkForDelete(tagPostModel); var tagPatchModel = new TagPatchModel { Id = id, Name = Tag2Name }; // Act var tagGetModel = TagClient.Update(tagPatchModel).AssertResult(); // Assert Assert.NotZero(tagGetModel.Id); Assert.AreEqual(Lowercase(tagPostModel.Color), tagGetModel.Color); Assert.AreEqual(tagPatchModel.Name, tagGetModel.Name); }
public void TagsBaseUrlTest() { string baseUrl = TagClient.TagsBaseUrl(ProjectId); baseUrl.Should().Be("projects/" + ProjectId + "/repository/tags"); }
private void Update() { _instance = instance; _localPlayer = localPlayer; _client = client; }
private void FindReferences() { client = GetComponent <TagClient>(); }