Beispiel #1
0
        public void MergeDisableDeleted()
        {
            var _targets = MergeDataGenerater.GetTargets();
            var _sources = MergeDataGenerater.GetSources();

            var _option = new DataMergeOption();

            _option.GetDeletedList = false;

            var _memberDataMerge = new MemberDataMerge(_option);

            _memberDataMerge.Merge(_targets, _sources);

            var _actualCreatedList = _memberDataMerge.Created;
            var _expectCreatedList = MergeDataGenerater.GetExpectCreatedList();

            Assert.Equal(_actualCreatedList, _expectCreatedList);

            var _actualUpdatedList = _memberDataMerge.Updated;
            var _expectUpdatedList = MergeDataGenerater.GetExpectUpdatedList();

            Assert.Equal(_actualUpdatedList, _expectUpdatedList);

            var _actualDeletedList = _memberDataMerge.Deleted;

            Assert.Null(_actualDeletedList);
        }
Beispiel #2
0
 public MemberDataMerge(DataMergeOption option) : base(option)
 {
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            List <Member> _target;
            List <Member> _source;

            _target = new List <Member>();
            _source = new List <Member>();

            _target.Add(new Member()
            {
                No = 1, Name = "Lucas Yang", Birthday = new DateTime(1984, 2, 13), Email = "*****@*****.**"
            });
            _target.Add(new Member()
            {
                No = 2, Name = "Peter Chang", Birthday = new DateTime(1975, 10, 29), Email = "*****@*****.**"
            });
            _target.Add(new Member()
            {
                No = 3, Name = "Will Pao", Birthday = new DateTime(1988, 2, 20), Email = "*****@*****.**"
            });
            _target.Add(new Member()
            {
                No = 6, Name = "Wei Chen", Birthday = new DateTime(1992, 1, 3), Email = "*****@*****.**"
            });

            _source.Add(new Member()
            {
                No = 2, Name = "Peter Chang", Birthday = new DateTime(1975, 10, 29), Email = "*****@*****.**"
            });
            _source.Add(new Member()
            {
                No = 3, Name = "Will Pao", Birthday = new DateTime(1988, 2, 29), Email = "*****@*****.**"
            });
            _source.Add(new Member()
            {
                No = 4, Name = "Lewis Wang", Birthday = new DateTime(1990, 9, 3), Email = "*****@*****.**"
            });
            _source.Add(new Member()
            {
                No = 5, Name = "Lucy Joy", Birthday = new DateTime(1991, 12, 25), Email = "*****@*****.**"
            });
            _source.Add(new Member()
            {
                No = 6, Name = "Wei Chen", Birthday = new DateTime(1992, 1, 3), Email = "*****@*****.**"
            });

            DataMergeOption _option;

            _option = new DataMergeOption();

            MemberDataMerge _merge = new MemberDataMerge(_option);

            _merge.Merge(_target, _source);

            Console.WriteLine("Created List");
            Console.WriteLine(JsonConvert.SerializeObject(_merge.Created, Formatting.Indented));

            Console.WriteLine();
            Console.WriteLine("Updated List");
            Console.WriteLine(JsonConvert.SerializeObject(_merge.Updated, Formatting.Indented));

            Console.WriteLine();
            Console.WriteLine("Deleted List");
            Console.WriteLine(JsonConvert.SerializeObject(_merge.Deleted, Formatting.Indented));

            //進行資料同步

            //取得要新增的清單

            //取得要更新的清單

            //取得要刪除的清單

            Console.WriteLine("press any key to exit !");
            Console.ReadKey();
        }