コード例 #1
0
        public void Grid_With_Valid_Id_Renders_Correctly()
        {
            // Arrange
            var testData = new[]
            {
                new { Name = "Name 1", Id = 1 },
                new { Name = "Name 2", Id = 2 }
            };

            var grid = GridFactory.CreateGrid <object>("TestId", testData);

            // Act
            var markup = grid.ToHtmlString();

            // Assert
            Assert.True(markup.Contains(@"<table>
    <thead>
        <tr>
            <th>Name</th><th>Id</th>
        </tr>
    </thead>
    <tbody data-bind=""foreach: seats"">
        <tr>
            <td data-bind=""text: Name""></td><td data-bind=""text: Id""></td>
        </tr>    
    </tbody>
</table>"));
        }
コード例 #2
0
        public void Passing_Id_And_Data_Creates_Grid_With_Matching_Id()
        {
            // Arrange
            var testData = new[]
            {
                new { Name = "Name 1", Id = 1 },
                new { Name = "Name 2", Id = 2 }
            };

            // Act
            var grid = GridFactory.CreateGrid("TestId", testData);

            // Assert
            Assert.Equal("TestId", grid.Id);
        }
コード例 #3
0
        public void Passing_null_For_Data_Throws_ArgumentNullException()
        {
            // Arrange
            bool argumentExceptionThrown = false;

            // Act
            try
            {
                var grid = GridFactory.CreateGrid <object>("TestId", null);
            }
            catch (ArgumentNullException)
            {
                argumentExceptionThrown = true;
            }

            Assert.True(argumentExceptionThrown);
        }
コード例 #4
0
        public void Passing_null_For_Id_Throws_ArgumentNullException()
        {
            // Arrange
            bool argumentExceptionThrown = false;
            var  testData = new[]
            {
                new { Name = "Name 1", Id = 1 },
                new { Name = "Name 2", Id = 2 }
            };

            // Act
            try
            {
                var grid = GridFactory.CreateGrid <object>(null, testData);
            }
            catch (ArgumentNullException)
            {
                argumentExceptionThrown = true;
            }

            Assert.True(argumentExceptionThrown);
        }
コード例 #5
0
        public void Apply()
        {
            var group = new Group(GridName);

            var wpts = GridFactory.CreateGrid(Corner, ProfileStep, SiteStep, ProfileLength, GridWidth, ProfileAngleDeg / 180.0 * Math.PI, GridAngleDeg / 180.0 * Math.PI);

            WaypointsService.Waypoints.AddRange(wpts.SelectMany(w => w));

            for (int i = 0; i < wpts.Count; i++)
            {
                var profileGroup = new ProfileGroup($"{group.Name} Профиль #:{i}");
                group.Children.Add(profileGroup);
                profileGroup.Children.AddRange(wpts[i]);
            }

            for (int i = 0; i < wpts[0].Count; i++)
            {
                var orthGroup = new ProfileGroup($"{group.Name} Пикет #:{i}");
                orthGroup.Children.AddRange(wpts.ConvertAll(wpt => wpt[i]));
                group.Children.Add(orthGroup);
            }

            GroupsService.Groups.Add(group);
        }