コード例 #1
0
        public void Roslyn_DynamicIEnumerable()
        {
            RunTestHelper(service =>
            {
                const string template = @"@Enumerable.Count(Model.Data)";
                const string expected = "3";
                var anonArray = new[] { new { InnerData = 1 }, new { InnerData = 2 }, new { InnerData = 3 } };
                var model = new { Data = anonArray.Select(a => a) };
                string result = service.RunCompile(template, "test", null, model, null);

                Assert.That(result == expected, "Result does not match expected: " + result);
            });
        }
コード例 #2
0
		public void AddManyUnrelatedElements()
		{
			// Arrange
			var sut = new OrderedRangedSet<int>();
			int[] arr = new [] { 1234, 123, 456, 5678, 789 };

			// Act
			foreach(int v in arr)
				sut.Add(v);

			// Assert
			Assert.That(sut.IsEmpty, Is.False);
			Assert.That(sut.Count, Is.EqualTo(arr.Length));
			Assert.That(sut, Is.EquivalentTo(arr.OrderBy(i => i)));
			foreach(int v in arr)
				Assert.That(sut.Contains(v), Is.True);
			Assert.That(sut.GetRanges(), Is.EquivalentTo(arr.Select(i => new Interval<int>(i, i + 1))));
		}
コード例 #3
0
ファイル: CodePointSetTests.cs プロジェクト: Virtlink/noofax
		public void AddManyUnrelatedElements()
		{
			// Arrange
			var sut = new CodePointSet();
			var arr = new [] { new CodePoint(1234), new CodePoint(123), new CodePoint(456), new CodePoint(5678), new CodePoint(789) };

			// Act
			foreach(var v in arr)
				sut.Add(v);

			// Assert
			Assert.That(sut.IsEmpty, Is.False);
			Assert.That(sut.Count, Is.EqualTo(arr.Length));
			Assert.That(sut, Is.EquivalentTo(arr.OrderBy(i => i)));
			foreach(var v in arr)
				Assert.That(sut.Contains(v), Is.True);
			Assert.That(sut.GetRanges(), Is.EquivalentTo(arr.Select(i => new CodePointRange(i, i))));
		}
コード例 #4
0
        public void Roslyn_AnonymousTypeWithinTemplate()
        {
            RunTestHelper(service =>
            {
                const string template_child = "@Enumerable.Count(Model.Data)";
                const string template_parent = @"@Include(""Child"", new { Data = Model.Data})";
                const string expected = "3";
                service.Compile(template_child, "Child", null);
                var anonArray = new[] { new { InnerData = 1 }, new { InnerData = 2 }, new { InnerData = 3 } };
                var model = new { Data = anonArray.Select(a => a) };
                string result = service.RunCompile(template_parent, "test", null, model, null);

                Assert.That(result == expected, "Result does not match expected: " + result);
            });
        }