schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using iWareCC.Common.Helper;
using iWareModel.Entity.MES;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace iWareUnitTest
{
    [TestClass]
    public class CSharpTest
    {
        /// <summary>
        /// 测试 写入异常对象
        /// </summary>
        [TestMethod]
        public void Test_RemoveList()
        {
            List<string> _list = new List<string>() {
                "11","22","33"
            };
 
            _list.RemoveAll(x => x == "11");
 
            Console.WriteLine(_list);
        }
 
        /// <summary>
        /// 测试 写入异常对象
        /// </summary>
        [TestMethod]
        public void Test_Contains()
        {
            List<int> _list = new List<int>() {
               1,11,111
            };
 
            List<int> _list2 = new List<int>() {
                1,11,111,1111,34,11111
            };
            var zz = _list2.Where(x => _list.Contains(x)).ToList();
 
            Console.WriteLine(_list);
        }
 
        /// <summary>
        /// 测试 其他方法的事情
        /// 测试结果:其他方法能改变 for循环中的对象
        /// </summary>
        [TestMethod]
        public void Test_OtherFunObject()
        {
            List<WareContainerType> _list = new List<WareContainerType>() {
              new WareContainerType(){ ContainerCode="aaa", WareMaterialTypeCode="aaa" },
              new WareContainerType(){ ContainerCode="bbb", WareMaterialTypeCode="bbb" },
              new WareContainerType(){ ContainerCode="ccc", WareMaterialTypeCode="ccc" },
            };
 
            foreach (var item in _list)
            {
                OtherTest(item);
            }
 
            foreach (var item in _list)
            {
                var zz = item;
            }
 
            Console.WriteLine(_list);
        }
 
 
        private void OtherTest(WareContainerType wareContainerType)
        {
            wareContainerType.ContainerCode = wareContainerType.WareMaterialTypeCode = "zzz";
        }
    }
}