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);
            });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }