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); }
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 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 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); }
/// <inheritdoc /> public ApiResult <TagGetModel> Update(TagPatchModel model) { return(Patch <TagPatchModel, TagGetModel>(model)); }
/// <inheritdoc /> public Task <ApiResult <TagGetModel> > UpdateAsync(TagPatchModel model, CancellationToken cancellationToken = default) { return(PatchAsync <TagPatchModel, TagGetModel>(model, cancellationToken)); }