//-------------------------------------------------------------------------------------- public void TestCaseSizeAsParameter() { int size = 10; List <string> expectedResult = new List <string>(); int limit = 1 << size; int[] binAsAray = new int[size]; for (int binAsNumber = 0; binAsNumber < limit; binAsNumber++) { int bin = binAsNumber; for (int i = size - 1; i >= 0; i--) { binAsAray[i] = bin & 1; bin >>= 1; } expectedResult.Add(string.Join(",", binAsAray.Select(t => t.ToString()))); } EnumerateBinVectorsSimple enumeration = new EnumerateBinVectorsSimple(size); // act enumeration.Execute(); // assert Assert.AreEqual(expectedResult.Count, enumeration.Result.Count, "Wrong number rows in result"); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], enumeration.Result[i], $"Wrong string in position {i} - {enumeration.Result[i]}. Expected - {expectedResult[i]}"); } }
//-------------------------------------------------------------------------------------- public void TestCaseSize4Manual() { List <string> expectedResult = new List <string>() { "0,0,0,0", "0,0,0,1", "0,0,1,0", "0,0,1,1", "0,1,0,0", "0,1,0,1", "0,1,1,0", "0,1,1,1", "1,0,0,0", "1,0,0,1", "1,0,1,0", "1,0,1,1", "1,1,0,0", "1,1,0,1", "1,1,1,0", "1,1,1,1" }; EnumerateBinVectorsSimple enumeration = new EnumerateBinVectorsSimple(4); // act enumeration.Execute(); // assert Assert.AreEqual(expectedResult.Count, enumeration.Result.Count, "Wrong number rows in result"); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], enumeration.Result[i], $"Wrong string in position {i} - {enumeration.Result[i]}. Expected - {expectedResult[i]}"); } }