コード例 #1
0
        public override void Process(ISolutionResourceContext data, ITestOutputContext output)
        {
            var files     = new List <string>();
            var identical = CollectionHelper.AreIdenticalByPairs(
                data.Values.ToArray(),
                (instanceA, instanceB) =>

                // compare IncludeFiles of all instances to ensure they are identical
                CollectionHelper.AreIdentical(
                    instanceA.SitecoreInfo.IncludeFiles,
                    instanceB.SitecoreInfo.IncludeFiles,
                    (nameA, nameB) => string.Equals(nameA, nameB, StringComparison.OrdinalIgnoreCase),
                    (fileA, fileB) =>
            {
                if (fileA == null)
                {
                    Assert.IsNotNull(fileB);

                    files.Add(fileB.FilePath.Substring(fileB.FilePath.IndexOf("App_Config")));
                    return(false);
                }

                if (fileB == null)
                {
                    Assert.IsNotNull(fileA);

                    files.Add(fileA.FilePath.Substring(fileA.FilePath.IndexOf("App_Config")));
                    return(false);
                }

                if (!string.Equals(fileA.RawText, fileB.RawText, StringComparison.Ordinal))
                {
                    files.Add(fileA.FilePath.Substring(fileA.FilePath.IndexOf("App_Config")));
                    return(false);
                }

                return(true);
            }));

            if (!identical)
            {
                output.Warning(ShortMessage, detailed: new DetailedMessage(new BulletedList(files)));
            }
        }
コード例 #2
0
        public void AreIdenticalTest(bool expected, string[] first, string[] second)
        {
            var dictA = new Dictionary <int, string>();

            for (var i = 0; i < first.Length; i += 2)
            {
                dictA.Add(int.Parse(first[i]), first[i + 1]);
            }

            var dictB = new Dictionary <int, string>();

            for (var i = 0; i < second.Length; i += 2)
            {
                dictB.Add(int.Parse(second[i]), second[i + 1]);
            }

            Assert.Equal(expected, CollectionHelper.AreIdentical(dictA, dictB, (a, b) => a == b, (a, b) => string.Equals(a, b, StringComparison.Ordinal)));
            Assert.Equal(expected, CollectionHelper.AreIdentical(dictB, dictA, (a, b) => a == b, (a, b) => string.Equals(a, b, StringComparison.Ordinal)));
        }
コード例 #3
0
 public void AreIdenticalTest(bool expected, int[] first, int[] second)
 {
     Assert.Equal(expected, CollectionHelper.AreIdentical(first, second, (a, b) => a == b));
     Assert.Equal(expected, CollectionHelper.AreIdentical(second, first, (a, b) => a == b));
 }