BVB Source Codes

Algorithm-Implementations Show FisherYatesTests.cs Source code

Return Download Algorithm-Implementations: download FisherYatesTests.cs Source code - Download Algorithm-Implementations Source code - Type:.cs
  1. 锘縰sing System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3.  
  4. namespace JamLib.Algorithms.Sorting.Tests
  5. {
  6.     [TestClass()]
  7.     public class SortingUtilsTests
  8.     {
  9.         [TestMethod()]
  10.         public void ShuffleTest()
  11.         {
  12.             int[] actual = new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  13.             int[] expected = new int[] { 8, 10, 5, 1, -1, 6, 9, 3, 0, 4, 2, 7 };
  14.             SortingUtils.Shuffle(actual);
  15.  
  16.             // Two collections are equivalent if they have the same elements in the same quantity, but in any order.
  17.             CollectionAssert.AreEquivalent(expected, actual, "The shuffle did not shuffle correctly");
  18.         }
  19.  
  20.         [TestMethod()]
  21.         public void Shuffle_SuppliedRNG_Test()
  22.         {
  23.             // using rng with a fixed seed so we can compare this shuffle against a previous shuffle with the same seed.
  24.             var random = new Random(1024);
  25.             int[] actual = new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  26.             int[] expected = new int[] { 8, 10, 5, 1, -1, 6, 9, 3, 0, 4, 2, 7 };
  27.             SortingUtils.Shuffle(actual, random);
  28.  
  29.             CollectionAssert.AreEqual(expected, actual, "The shuffle did not produce the expected result");
  30.         }
  31.  
  32.         [TestMethod()]
  33.         public void Shuffle_ExtensionMethod_Test()
  34.         {
  35.             int[] actual = new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  36.             int[] expected = new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  37.             actual.Shuffle();
  38.  
  39.             CollectionAssert.AreEquivalent(expected, actual);
  40.         }
  41.  
  42.         [TestMethod()]
  43.         public void Shuffle_Empty_Test()
  44.         {
  45.             int[] actual = new int[0];
  46.             int[] expected = new int[0];
  47.             SortingUtils.Shuffle(actual);
  48.  
  49.             CollectionAssert.AreEquivalent(expected, actual);
  50.         }
  51.     }
  52. }
  53.  
downloadFisherYatesTests.cs Source code - Download Algorithm-Implementations Source code
Related Source Codes/Software:
raty - 2017-04-22
RDVTabBarController - Highly customizable tabBar and tabBarController fo... 2017-04-22
material-icon-lib - Library containing over 1500 material vector icons... 2017-04-21
httpdiff - Perform the same request against two HTTP servers ... 2017-04-21
jquerytools - The missing UI library for the Web ... 2017-04-21
mcrouter - Mcrouter is a memcached protocol router for scalin... 2017-04-22
dynomite - A generic dynamo implementation for different k-v ... 2017-04-22
kityminder - Baidu brain figure 2017-04-22
llvm - Mirror of official llvm git repository located at ... 2017-04-22
RBBAnimation - Block-based animations made easy, comes with easin... 2017-04-22
ied - 2017-04-29
Nimble - A Matcher Framework for Swift and Objective-C 2017-04-29
MHVideoPhotoGallery - A Photo and Video Gallery 2017-04-29
shoulda-matchers - Collection of testing matchers extracted from Shou... 2017-04-29
Android-SlideExpandableListView - A better ExpandableListView, with animated expanda... 2017-04-29
AppSales-Mobile - App Sales allows iPhone and Mac App Store develope... 2017-04-29
react-templates - Light weight templates for react ... 2017-04-28
afterglow-theme - A minimal dark Theme for Sublime Text 2 and 3 2017-04-28
jwt-go - Golang implementation of JSON Web Tokens (JWT) 2017-04-28
DeerResume - Tool MarkDown online resume, online preview, edit,... 2017-04-28

 Back to top