Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public ApiResult <TagGetModel> Update(TagPatchModel model)
 {
     return(Patch <TagPatchModel, TagGetModel>(model));
 }
Exemplo n.º 6
0
 /// <inheritdoc />
 public Task <ApiResult <TagGetModel> > UpdateAsync(TagPatchModel model, CancellationToken cancellationToken = default)
 {
     return(PatchAsync <TagPatchModel, TagGetModel>(model, cancellationToken));
 }