private static IEnumerable <TestCaseData> GetRowTestCases() { var matrix = RefMatrix4x4.FromSystem2DArray( new float[, ] { { 1, 2, 3, 4 }, { 9, 8, 7, 6 }, { 3, 6, 12, 24 }, { 5, 25, 125, 625 } }); var firstRow = new RefRow <float, RefMatrix4x4>( RefMatrix4x4.FromSystem2DArray( new float[, ] { { 1, 2, 3, 4 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }), 0); var lastRow = new RefRow <float, RefMatrix4x4>( RefMatrix4x4.FromSystem2DArray( new float[, ] { { 5, 25, 125, 625 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }), 0); yield return(new TestCaseData(matrix, 0, firstRow)); yield return(new TestCaseData(matrix, 3, lastRow)); }
public static void TestFillWith <T, TRefRectangularCollection, TEnumerable>( RefRow <T, TRefRectangularCollection> actual, T value, TEnumerable expected) where TRefRectangularCollection : IRefRectangularCollection <T> where TEnumerable : IEnumerable <T> { actual.FillWith(value); CollectionAssert.AreEqual(expected, actual); }
public static void TestReverse <T, TRefRectangularCollection, TEnumerable>( RefRow <T, TRefRectangularCollection> actual, TEnumerable expected) where TRefRectangularCollection : IRefRectangularCollection <T> where TEnumerable : IEnumerable <T> { actual.Reverse(); CollectionAssert.AreEqual(expected, actual); }
public IActionResult Search(string term) { var results = new List <RefRow>(); SqlConnection cnn; cnn = new SqlConnection(connectionString); SqlCommand command; SqlDataAdapter adapter = new SqlDataAdapter(); cnn.Open(); //Two SQL queries that check the search term in both the first and last name column string q1 = "SELECT fname, lname, dob, clientCode from refform where fname = '" + term + "';"; string q2 = "SELECT fname, lname, dob, clientCode from refform where lname = '" + term + "';"; command = new SqlCommand(q1, cnn); SqlDataReader reader = command.ExecuteReader(); //check first name while (reader.Read()) { //We push information from the query into a row and onto the list of rows RefRow row = new RefRow { fname = reader.GetString(reader.GetOrdinal("fname")), lname = reader.GetString(1), dob = reader.GetDateTime(2).ToString("dd MMMM yyyy"), clientCode = reader.GetGuid(3) }; results.Add(row); } reader.Close(); //check last name command = new SqlCommand(q2, cnn); SqlDataReader reader2 = command.ExecuteReader(); while (reader2.Read()) { RefRow row = new RefRow { fname = reader2.GetString(reader2.GetOrdinal("fname")), lname = reader2.GetString(1), dob = reader2.GetDateTime(2).ToString("dd MMMM yyyy"), clientCode = reader2.GetGuid(3) }; results.Add(row); } reader2.Close(); return(View("RefList", results)); }
protected void dlRefTable_ItemDataBound(Object sender, DataListItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Header: // grab controls Literal litHeader = (Literal)e.Item.FindControl("litHeader"); litHeader.Text = headerText; break; case ListItemType.Item: case ListItemType.AlternatingItem: // grab struct RefRow refRow = (RefRow)e.Item.DataItem; // grab controls TableRow trRef = (TableRow)e.Item.FindControl("trRef"); Literal litElement = (Literal)e.Item.FindControl("litElement"); Literal litDefinition = (Literal)e.Item.FindControl("litDefinition"); HyperLink hlExample = (HyperLink)e.Item.FindControl("hlExample"); // set stuff litElement.Text = refRow.Element; litDefinition.Text = refRow.Definition; if (!string.IsNullOrEmpty(refRow.ExampleUrl)) { hlExample.NavigateUrl = refRow.ExampleUrl; } else { hlExample.Visible = false; } // row visibility if (!refRow.IsVisible) { // hide row via CSS (but still render HTML so it can be made visible client-side) trRef.Style["display"] = "none"; } break; } }
private static IEnumerable <TestCaseData> GetRowTestCases() { var array2x3 = Array2D <int> .FromSystem2DArray( new int[, ] { { 4, 3, 7 }, { 8, 9, 2 } }); var firstRow = new RefRow <int, Array2D <int> >(new Array2D <int>(1, 3), 0); firstRow[0] = 4; firstRow[1] = 3; firstRow[2] = 7; var lastRow = new RefRow <int, Array2D <int> >(new Array2D <int>(1, 3), 0); lastRow[0] = 8; lastRow[1] = 9; lastRow[2] = 2; yield return(new TestCaseData(array2x3, 0, firstRow)); yield return(new TestCaseData(array2x3, 1, lastRow)); }
public static void GetRowTest( RefMatrix4x4 matrix, int index, RefRow <float, RefMatrix4x4> expected) => CollectionAssert.AreEqual(expected, matrix.GetRow <float, RefMatrix4x4>(index));
public static void IsValidIndexReturnsFalseOnInvalidIndexArguments <T>( RefRow <T, Array2D <T> > indexable, int index) => RefIndexableTests.IsValidIndexReturnsFalseOnInvalidIndexArguments <T, RefRow <T, Array2D <T> > >(indexable, index);
public static void TestIndexer <T>( RefRow <T, Array2D <T> > indexable, int index, T expected) => RefIndexableTests.TestIndexer(indexable, index, expected);
public static void TestFillWith <T, TEnumerable>( RefRow <T, Array2D <T> > actual, T value, TEnumerable expected) where TEnumerable : IEnumerable <T> => RefRowTests.TestFillWith(actual, value, expected);
public static void TestReverse <T, TEnumerable>( RefRow <T, Array2D <T> > actual, TEnumerable expected) where TEnumerable : IEnumerable <T> => RefRowTests.TestReverse(actual, expected);
public static void IndexerThrowsExceptionIfIndexIsOutOfBounds <T>( RefRow <T, Array2D <T> > row, int index) => RefRowTests.IndexerThrowsExceptionIfIndexIsOutOfBounds(row, index);
public static void CountEqualsCollectionLength2 <T>( Array2D <T> collection, RefRow <T, Array2D <T> > row) => RefRowTests.CountEqualsCollectionLength2(collection, row);
public static void GetRowTest <T>( List2D <T> list, int index, RefRow <T, List2D <T> > expected) => CollectionAssert.AreEqual(expected, list.GetRow(index));
public static void CountEqualsCollectionLength2 <T, TRefRectangularCollection>( TRefRectangularCollection collection, RefRow <T, TRefRectangularCollection> row) where TRefRectangularCollection : IRefRectangularCollection <T> => Assert.AreEqual(collection.Boundaries.Length2, row.Count);
public static void GetRowTest <T>( Array2D <T> array, int index, RefRow <T, Array2D <T> > expected) => CollectionAssert.AreEqual(expected, array.GetRow(index));
public static void TestEquality <T, TEnumerable>( RefRow <T, List2D <T> > actual, TEnumerable expected) where TEnumerable : IEnumerable <T> => RefRowTests.TestEquality(actual, expected);
public static void IndexerThrowsExceptionIfIndexIsOutOfBounds <T, TRefRectangularCollection>( RefRow <T, TRefRectangularCollection> row, int index) where TRefRectangularCollection : IRefRectangularCollection <T> => Assert.Throws <IndexOutOfRangeException>(() => { T value = row[index]; });