tests/DotNetCommon.Test/Extensions/ObjectTests_Modify.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using DotNetCommon.Data;
using NUnit.Framework;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetCommon.Extensions;
namespace DotNetCommon.Test.Extensions
{
[TestFixture]
public class ObjectTests_Modify
{
[Test]
public void Test()
{
var res = getData();
res.Data.Students.Count.ShouldBeGreaterThan(1);
res.Data.Students[0].CellPhone.ShouldNotBe("****");
res.Data.Students[1].CellPhone.ShouldNotBe("****");
res.Data.OtherStudents.Length.ShouldBeGreaterThan(1);
res.Data.OtherStudents[0].CellPhone.ShouldNotBe("****");
res = res.Modify("CellPhone", old => "****");
res.Data.Students.Count.ShouldBeGreaterThan(1);
res.Data.Students[0].CellPhone.ShouldBe("****");
res.Data.Students[1].CellPhone.ShouldBe("****");
res.Data.OtherStudents.Length.ShouldBeGreaterThan(1);
res.Data.OtherStudents[0].CellPhone.ShouldBe("****");
res = res.Modify("Students", old => new List<Student>());
res.Data.Students.Count.ShouldBe(0);
}
private Result<Person> getData()
{
return Result.Ok<Person>(new Person()
{
Id = 1,
Name = "王二小",
IdentityCard = "412314200001021234",
Students = new List<Student>()
{
new Student()
{
Id=2,
Name="张飞",
CellPhone="18742312541"
},
new Student()
{
Id=3,
Name="东方不败",
CellPhone="15012345678"
}
},
OtherStudents = new Student[3]
{
后面还有 35 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
