• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Test.SimpleDTOWithNestedDTO类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.JsonPatch.Test.SimpleDTOWithNestedDTO的典型用法代码示例。如果您正苦于以下问题:C# SimpleDTOWithNestedDTO类的具体用法?C# SimpleDTOWithNestedDTO怎么用?C# SimpleDTOWithNestedDTO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SimpleDTOWithNestedDTO类属于Microsoft.AspNet.JsonPatch.Test命名空间,在下文中一共展示了SimpleDTOWithNestedDTO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ReplacePropertyInNestedObject

        public void ReplacePropertyInNestedObject()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                IntegerValue = 1
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace<string>(o => o.NestedDTO.StringProperty, "B");

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal("B", doc.NestedDTO.StringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:18,代码来源:NestedObjectTests.cs


示例2: AddResultsInReplace

        public void AddResultsInReplace()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A"
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Add<string>(o => o.SimpleDTO.StringProperty, "B");

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal("B", doc.SimpleDTO.StringProperty);
        }
开发者ID:slideroom,项目名称:JsonPatch,代码行数:21,代码来源:NestedObjectTests.cs


示例3: ReplacePropertyInNestedObjectWithSerialization

        public void ReplacePropertyInNestedObjectWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                IntegerValue = 1
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace<string>(o => o.NestedDTO.StringProperty, "B");

            // serialize & deserialize
            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal("B", doc.NestedDTO.StringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:NestedObjectTests.cs


示例4: AddResultsInReplaceWithSerialization

        public void AddResultsInReplaceWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A"
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Add<string>(o => o.SimpleDTO.StringProperty, "B");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal("B", doc.SimpleDTO.StringProperty);
        }
开发者ID:slideroom,项目名称:JsonPatch,代码行数:24,代码来源:NestedObjectTests.cs


示例5: ReplaceInListWithSerialization

        public void ReplaceInListWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace<int>(o => o.SimpleDTO.IntegerList, 5, 0);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 5, 2, 3 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:24,代码来源:NestedObjectTests.cs


示例6: SerializationTests

        public void SerializationTests()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A",
                    DecimalValue = 10,
                    DoubleValue = 10,
                    FloatValue = 10,
                    IntegerValue = 10
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace(o => o.SimpleDTO.StringProperty, "B");
            patchDoc.Replace(o => o.SimpleDTO.DecimalValue, 12);
            patchDoc.Replace(o => o.SimpleDTO.DoubleValue, 12);
            patchDoc.Replace(o => o.SimpleDTO.FloatValue, 12);
            patchDoc.Replace(o => o.SimpleDTO.IntegerValue, 12);

            // serialize & deserialize
            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserizalized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserizalized.ApplyTo(doc);

            // Assert
            Assert.Equal("B", doc.SimpleDTO.StringProperty);
            Assert.Equal(12, doc.SimpleDTO.DecimalValue);
            Assert.Equal(12, doc.SimpleDTO.DoubleValue);
            Assert.Equal(12, doc.SimpleDTO.FloatValue);
            Assert.Equal(12, doc.SimpleDTO.IntegerValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:37,代码来源:NestedObjectTests.cs


示例7: RemoveFromListInvalidPositionTooSmall_LogsError

        public void RemoveFromListInvalidPositionTooSmall_LogsError()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Remove<int>(o => o.SimpleDTO.IntegerList, -1);

            var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();

            // Act
            patchDoc.ApplyTo(doc, logger.LogErrorMessage);

            // Assert
            Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", logger.ErrorMessage);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:23,代码来源:NestedObjectTests.cs


示例8: RemoveFromListInvalidPositionTooLarge_LogsError

        public void RemoveFromListInvalidPositionTooLarge_LogsError()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Remove<int>(o => o.SimpleDTO.IntegerList, 3);

            var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();

            // Act
            patchDoc.ApplyTo(doc, logger.LogErrorMessage);

            // Assert
            Assert.Equal(
                "For operation 'remove' on array property at path '/simpledto/integerlist/3', the index is " +
                    "larger than the array size.",
                logger.ErrorMessage);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:26,代码来源:NestedObjectTests.cs


示例9: Remove

        public void Remove()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A"
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Remove<string>(o => o.SimpleDTO.StringProperty);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(null, doc.SimpleDTO.StringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:21,代码来源:NestedObjectTests.cs


示例10: AddToListInvalidPositionTooSmall

        public void AddToListInvalidPositionTooSmall()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Add<int>(o => o.SimpleDTO.IntegerList, 4, -1);

            // Act & Assert
            var exception = Assert.Throws<JsonPatchException<SimpleDTOWithNestedDTO>>(() => { patchDoc.ApplyTo(doc); });
            Assert.Equal("Property does not exist at path '/simpledto/integerlist/-1'.", exception.Message);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:19,代码来源:NestedObjectTests.cs


示例11: MoveFomListToNonListBetweenHierarchy

        public void MoveFomListToNonListBetweenHierarchy()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Move<int>(o => o.SimpleDTO.IntegerList, 0, o => o.IntegerValue);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 2, 3 }, doc.SimpleDTO.IntegerList);
            Assert.Equal(1, doc.IntegerValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:NestedObjectTests.cs


示例12: MoveWithSerialization

        public void MoveWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A",
                    AnotherStringProperty = "B"
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Move<string>(o => o.SimpleDTO.StringProperty, o => o.SimpleDTO.AnotherStringProperty);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal("A", doc.SimpleDTO.AnotherStringProperty);
            Assert.Equal(null, doc.SimpleDTO.StringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:26,代码来源:NestedObjectTests.cs


示例13: CopyFromNonListToList

        public void CopyFromNonListToList()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerValue = 5,
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<int>(o => o.SimpleDTO.IntegerValue, o => o.SimpleDTO.IntegerList, 0);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 5, 1, 2, 3 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:NestedObjectTests.cs


示例14: Copy

        public void Copy()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A",
                    AnotherStringProperty = "B"
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<string>(o => o.SimpleDTO.StringProperty, o => o.SimpleDTO.AnotherStringProperty);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal("A", doc.SimpleDTO.AnotherStringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:NestedObjectTests.cs


示例15: ReplaceFullListWithCollection

        public void ReplaceFullListWithCollection()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace<IEnumerable<int>>(o => o.SimpleDTO.IntegerList, new Collection<int>() { 4, 5, 6 });

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 4, 5, 6 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:21,代码来源:NestedObjectTests.cs


示例16: ReplaceInListInvalidInvalidPositionTooLargeWithSerialization

        public void ReplaceInListInvalidInvalidPositionTooLargeWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Replace<int>(o => o.SimpleDTO.IntegerList, 5, 3);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act & Assert
            Assert.Throws<JsonPatchException<SimpleDTOWithNestedDTO>>(() => { deserialized.ApplyTo(doc); });
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:21,代码来源:NestedObjectTests.cs


示例17: AddToListInvalidPositionTooLarge

        public void AddToListInvalidPositionTooLarge()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Add<int>(o => o.SimpleDTO.IntegerList, 4, 4);

            // Act & Assert
            var exception = Assert.Throws<JsonPatchException<SimpleDTOWithNestedDTO>>(() => { patchDoc.ApplyTo(doc); });
            Assert.Equal(
                "For operation 'add' on array property at path '/simpledto/integerlist/4', the index is " +
                    "larger than the array size.", 
                exception.Message);

        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:23,代码来源:NestedObjectTests.cs


示例18: MoveFomListToNonListBetweenHierarchyWithSerialization

        public void MoveFomListToNonListBetweenHierarchyWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Move<int>(o => o.SimpleDTO.IntegerList, 0, o => o.IntegerValue);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 2, 3 }, doc.SimpleDTO.IntegerList);
            Assert.Equal(1, doc.IntegerValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:25,代码来源:NestedObjectTests.cs


示例19: AddToListAppend

        public void AddToListAppend()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Add<int>(o => o.SimpleDTO.IntegerList, 4);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 1, 2, 3, 4 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:21,代码来源:NestedObjectTests.cs


示例20: MoveToEndOfList

        public void MoveToEndOfList()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerValue = 5,
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Move<int>(o => o.SimpleDTO.IntegerValue, o => o.SimpleDTO.IntegerList);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(0, doc.IntegerValue);
            Assert.Equal(new List<int>() { 1, 2, 3, 5 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:23,代码来源:NestedObjectTests.cs



注:本文中的Microsoft.AspNet.JsonPatch.Test.SimpleDTOWithNestedDTO类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mvc.ActionContext类代码示例发布时间:2022-05-26
下一篇:
C# Test.SimpleDTO类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap