コード例 #1
0
        public void CompareFragmentLists_DetectsNewCodeFragment()
        {
            var oldList = new List <CodeFragment>
            {
                new CodeFragment
                {
                    Identifier = "hello-world",
                    Content    = "console.log('Hello Kentico Cloud');",
                    Language   = CodeFragmentLanguage.JavaScript,
                    Platform   = CodeFragmentPlatform.JavaScript
                }
            };

            var newList = new List <CodeFragment>
            {
                new CodeFragment
                {
                    Identifier = "hello-world",
                    Content    = "console.log('Hello Kentico Cloud');",
                    Language   = CodeFragmentLanguage.JavaScript,
                    Platform   = CodeFragmentPlatform.JavaScript
                },
                new CodeFragment
                {
                    Identifier = "hello-world",
                    Content    = "Console.WriteLine(\"Hello World!\");",
                    Language   = CodeFragmentLanguage.CSharp,
                    Platform   = CodeFragmentPlatform.Net
                }
            };

            var expectedFragment = new CodeFragment
            {
                Identifier = "hello-world",
                Content    = "Console.WriteLine(\"Hello World!\");",
                Language   = CodeFragmentLanguage.CSharp,
                Platform   = CodeFragmentPlatform.Net
            };

            var(newFragments, modifiedFragments, removedFragments) = _codeConverter.CompareFragmentLists(oldList, newList);

            Assert.That(newFragments, Does.Contain(expectedFragment).UsingCodeFragmentComparer());
            Assert.That(modifiedFragments, Is.Empty);
            Assert.That(removedFragments, Is.Empty);
        }