public void TestCompare_Validate()
        {
            var list = new List <AggregateRootSample>();

            AssertHelper.Throws <ArgumentNullException>(() => {
                _comparator.Compare(null, list);
            });
            AssertHelper.Throws <ArgumentNullException>(() => {
                _comparator.Compare(list, null);
            });
            AssertHelper.Throws <ArgumentNullException>(() => {
                list.Compare(null);
            });
        }
예제 #2
0
        public void TestCompare_CreateList()
        {
            var id      = Guid.NewGuid();
            var newList = new List <AggregateRootSample>
            {
                new AggregateRootSample(id)
                {
                    Name = "a"
                }
            };
            var result = _comparator.Compare(newList, new List <AggregateRootSample>());

            Assert.Single(result.CreateList);
            Assert.Equal("a", result.CreateList[0].Name);
        }
예제 #3
0
        /// <summary>
        /// 比较
        /// </summary>
        /// <typeparam name="TEntity">实体类型</typeparam>
        /// <typeparam name="TKey">标识类型</typeparam>
        /// <param name="newList">新实体集合</param>
        /// <param name="oldList">旧实体集合</param>
        public static ListCompareResult <TEntity, TKey> Compare <TEntity, TKey>(this IEnumerable <TEntity> newList, IEnumerable <TEntity> oldList)
            where TEntity : IKey <TKey>
        {
            var comparator = new ListComparator <TEntity, TKey>();

            return(comparator.Compare(newList, oldList));
        }
예제 #4
0
        public void Compare_ShouldReturnAmountOfTheValuesFromListOneInListTwo(IEnumerable <int> firstList, IEnumerable <int> secondList, int expectedResult)
        {
            var testee = new ListComparator();

            var result = testee.Compare(firstList, secondList);

            result.Should().Be(expectedResult);
        }