public static void Test(Assert assert)
        {
            assert.Expect(4);

            // TEST
            int[] numbersA = { 4, 1, 3 };
            int[] numbersB = { 2, 3, 5 };

            var concatNumbers = numbersA.Concat(numbersB);
            assert.DeepEqual(concatNumbers, new[] { 4, 1, 3, 2, 3, 5 }, "Concat() numbers");

            // TEST
            var names = from p in Person.GetPersons()
                        select p.Name;
            var cities = from p in Person.GetPersons()
                         select p.City;
            var concatNames = names.Concat(cities).ToArray();

            assert.DeepEqual(concatNames,
                            new[] { "Frank", "Zeppa", "John", "Billy", "Dora", "Ian", "Mary", "Nemo",
                                    "Edmonton", "Tokyo", "Lisbon", "Paris", "Budapest", "Rome", "Dortmund", "Ocean"},
                            "Concat() two sequences");

            // TEST
            var a = new[] { "a", "b", "z" };
            var b = new[] { "a", "b", "z" };

            assert.Ok(a.SequenceEqual(b), "SequenceEqual() for equal sequences");

            // TEST
            var c = new[] { "a", "b", "z" };
            var d = new[] { "a", "z", "b" };

            assert.Ok(!c.SequenceEqual(d), "SequenceEqual() for not equal sequences");
        }
        public void SequenceEqual_compares_items_using_provided_equality_function()
        {
            var first = new[] { "a", "A" };
            var second = new[] { "A", "a" };

            Assert.True(first.SequenceEqual(second, (a, b) => a.Equals(b, StringComparison.OrdinalIgnoreCase)));
        }
        public void Can_Shuffle()
        {
            var items = new[] {"Foo", "Bar", "Baz", "Boo", "Alexander", "Nyquist"};
            var shuffled = items.Shuffle();

            Assert.IsFalse(items.SequenceEqual(shuffled));
        }
Esempio n. 4
0
        public void TranslationsFlatToTranslations()
        {
            var arr = new[] {"Test1", "Test2"};
            var data = JsonConvert.SerializeObject(arr);
            var state = new WordState { TranslationsFlat=data};

            Assert.IsTrue(arr.SequenceEqual(state.Translations));
        }
        public void ShouldApplyLimitUsingTop()
        {
            var sql = "select a,b,c from d where a = 1 order by c";
            var expected = new[]{ "select top 5 a,b,c from d where a = 1 order by c"};

            var pagedSql = new VistaDBQueryPager().ApplyLimit(sql, 5);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
        public void ShouldCopeWithAliasedDefaultSortColumn()
        {
            var sql = "select [a] as [foo],[b],[c] from [d] where [a] = 1";
            var expected = new[]{
                "with __data as (select [a] as [foo],[b],[c], row_number() over(order by [a]) as [_#_] from [d] where [a] = 1)"
                + " select [foo],[b],[c] from __data where [_#_] between 31 and 40"};

            var pagedSql = new VistaDBQueryPager().ApplyPaging(sql, 30, 10);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
        public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
        {
            var sql = "select a,b,c from d where a = 1";
            var expected = new[]{
                "with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
                + " select a,b,c from __data where [_#_] between 11 and 30"};

            var pagedSql = new VistaDBQueryPager().ApplyPaging(sql, 10, 20);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
		public void GetAllTypesTest (ModuleDefinition module)
		{
			var sequence = new [] {
				module.GetType ("<Module>"),
				module.GetType ("Foo"),
				module.GetType ("Foo/Bar"),
				module.GetType ("Foo/Gazonk"),
				module.GetType ("Foo/Gazonk/Baz"),
				module.GetType ("Pan"),
			};

			Assert.IsTrue (sequence.SequenceEqual (module.GetAllTypes ()));
		}
        public void ShouldReturnFilePath()
        {
            var root = Client.GetFolder(FolderID.Root).ID;
            var parent = Client.CreateFolder(root, "TestGetFileParent").ID;
            var name = "TestGetFile";
            var file = Client.CreateFile(parent, name).ID;
            var path = new[] { root, parent };

            var filePath = Client.GetFilePath(file);

            Assert.IsNotNull(filePath);
            Assert.IsTrue(path.SequenceEqual(filePath.Folders.Select(folder => folder.ID)));
        }
Esempio n. 10
0
        public void GetAllTypesTest()
        {
            TestCSharp ("Types.cs", module => {
                var sequence = new [] {
                module.GetType ("<Module>"),
                module.GetType ("Foo"),
                module.GetType ("Foo/Bar"),
                module.GetType ("Foo/Gazonk"),
                module.GetType ("Foo/Gazonk/Baz"),
                module.GetType ("Pan"),
            };

                Assert.IsTrue (sequence.SequenceEqual (module.GetAllTypes ()));
            });
        }
Esempio n. 11
0
        public void CollectionExtensions_Creation_Snapshot()
        {
            var expected = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var result = _target.Select(x => x).Snapshot();
            var resultValue = result();

            Assert.IsTrue(_target.SequenceEqual(resultValue));

            for (int i = 0; i < _target.Length; i++)
                _target[i] *= 2;

            resultValue = result();

            Assert.IsTrue(expected.SequenceEqual(resultValue));
        }
        public void GetOverridenCspPluginTypesConfig_NoMediaTypesOverride_KeepsMediaTypes()
        {
            var expectedMediaTypes = new[] { "application/pdf" };
            var directiveConfig = new CspPluginTypesDirectiveConfiguration { MediaTypes = expectedMediaTypes };
            var directiveOverride = new CspPluginTypesOverride { InheritMediaTypes = true };

            var newConfig = _overrideHelper.GetOverridenCspPluginTypesConfig(directiveOverride, directiveConfig);

            Assert.IsTrue(expectedMediaTypes.SequenceEqual(newConfig.MediaTypes), "MediaTypes differed.");
        }
        public void GetOverridenCspDirectiveConfig_NoCustomSourcesOverride_KeepsCustomSources()
        {
            var expectedSources = new[] { "www.nwebsec.com" };
            var directiveConfig = new CspDirectiveConfiguration { CustomSources = expectedSources };
            var directiveOverride = new CspDirectiveOverride { InheritOtherSources = true };

            var newConfig = _overrideHelper.GetOverridenCspDirectiveConfig(directiveOverride, directiveConfig);

            Assert.IsTrue(expectedSources.SequenceEqual(newConfig.CustomSources), "CustomSources differed.");
        }