public void Test_isActive_dataMod() { // Arrange int[] seq = new int[] { 1, 9, 3, 7, 5, 6, 4, 8, 2, 10 }; int prime = 7; dataMod obj = new dataMod(prime, seq); int[] expectedLARGE = new int[] { 10, 9, 8, 4, 6, 2, 2, 2, 2, 1 }; int[] expectedSMALL = new int[] { 1, 2, 2, 2, 2, 6, 4, 8, 9, 10 }; int[] expectedInactiveSeq = null; bool expectedActive = false; // Act int[] resultLARGE = obj.scramble(); obj.switchMode(); int[] resultSMALL = obj.scramble(); obj.switchMode(); int[] resultInactive = obj.scramble(); bool activeState = obj.getActiveStatus(); // Assert CollectionAssert.AreEqual(resultLARGE, expectedLARGE); CollectionAssert.AreEqual(resultSMALL, expectedSMALL); CollectionAssert.AreEqual(resultInactive, expectedInactiveSeq); Assert.AreEqual(activeState, expectedActive); }
public void Test_scramble_dataMod() { // Arrange int[] seq = new int[] { 1, 9, 3, 7, 5, 6, 4, 8, 2, 10 }; int prime = 7; dataMod objLARGE = new dataMod(prime, seq); dataMod objSMALL = new dataMod(prime, seq); dataMod objNullLARGE = new dataMod(prime); dataMod objNullSMALL = new dataMod(prime); int[] expectedLARGE = new int[] { 10, 9, 8, 4, 6, 2, 2, 2, 2, 1 }; int[] expectedSMALL = new int[] { 1, 2, 2, 2, 2, 6, 4, 8, 9, 10 }; int[] expectedNullLARGE = expectedLARGE; int[] expectedNullSMALL = expectedSMALL; // Act objSMALL.switchMode(); objNullSMALL.switchMode(); int[] resultLARGE = objLARGE.scramble(); int[] resultSMALL = objSMALL.scramble(); int[] resultNullLARGE = objNullLARGE.scramble(seq); int[] resultNullSMALL = objNullSMALL.scramble(seq); // Assert CollectionAssert.AreEqual(resultLARGE, expectedLARGE); CollectionAssert.AreEqual(resultSMALL, expectedSMALL); CollectionAssert.AreEqual(resultNullLARGE, expectedNullLARGE); CollectionAssert.AreEqual(resultNullSMALL, resultNullSMALL); }
public void Test_filter_dataMod() { // Arrange int[] seq = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int prime = 7; dataMod objLARGE = new dataMod(prime, seq); dataMod objSMALL = new dataMod(prime, seq); dataMod objNullLARGE = new dataMod(prime); dataMod objNullSMALL = new dataMod(prime); int[] expectedLARGE = new int[] { 9, 10, 11 }; int[] expectedSMALL = new int[] { 0, 1, 2, 3, 4, 5 }; int[] expectedNullLARGE = new int[] { 7 }; int[] expectedNullSMALL = new int[] { 7 }; // Act objSMALL.switchMode(); objNullSMALL.switchMode(); int[] resultLARGE = objLARGE.filter(); int[] resultSMALL = objSMALL.filter(); int[] resultNullLARGE = objNullLARGE.filter(); int[] resultNullSMALL = objNullSMALL.filter(); // Assert CollectionAssert.AreEqual(resultLARGE, expectedLARGE); CollectionAssert.AreEqual(resultSMALL, expectedSMALL); CollectionAssert.AreEqual(resultNullLARGE, expectedNullLARGE); CollectionAssert.AreEqual(resultNullSMALL, expectedNullSMALL); }
public void Test_dataMod_ScrambleOddLengthSeq() { // Arrange dataMod d = new dataMod(); int[] testArray = new int[7] { 8, 24, 30, 31, 6, 11, 66 }; int[] assertArray = new int[7] { 8, 24, 2, 30, 2, 6, 66 }; // Act int[] dScramble = d.scramble(testArray); // Assert CollectionAssert.AreEqual(dScramble, assertArray); }
public void Test_dataMod_ScrambleLargeMode() { // Arrange dataMod d = new dataMod(); d.setMode(true); int[] testArray = new int[6] { 8, 24, 30, 31, 6, 11 }; int[] assertArray = new int[6] { 24, 8, 30, 2, 6, 2 }; // Act int[] dScramble = d.scramble(testArray); // Assert CollectionAssert.AreEqual(dScramble, assertArray); }
public void Test_dataMod_FilterSmallMode() { // Arrange dataMod d = new dataMod(13); int[] testArray = new int[6] { 8, 24, 30, 31, 6, 11 }; int[] assertArray = new int[4] { 7, 1, 5, 1 }; // Act d.scramble(testArray); // NOTE: All prime numbers will be replaced with '2' before updating int[] dFilter = d.filter(); // Assert CollectionAssert.AreEqual(dFilter, assertArray); }
static void Main(string[] args) { int N = 30000; data data1 = new data(); Thread th0 = new Thread(()=> { DateTime dt = DateTime.Now; //Console.WriteLine(dt.ToString("fff")); for (int i = 0; i < N; i++) { Thread.Sleep(1); // Console.WriteLine("Thread 0"); data1.x++; } //Console.WriteLine(DateTime.Now.ToString("fff")); var tmp = -(Convert.ToInt32(dt.ToString("fff"))) + Convert.ToInt32(DateTime.Now.ToString("fff")); Console.WriteLine("Всего затрачено(рядом) {0} ms", tmp); }); Thread th1 = new Thread(() => { for (int i = 0; i < N; i++) { Thread.Sleep(2); // Console.WriteLine("Thread 1"); data1.y++; } }); th0.IsBackground = true; th1.IsBackground = true; th0.Start(); th1.Start(); //--- dataMod data = new dataMod(); Thread th2 = new Thread(() => { DateTime dt = DateTime.Now; //Console.WriteLine(dt.ToString("fff")); for (int i = 0; i < N; i++) { Thread.Sleep(1); // Console.WriteLine("Thread 0"); data.x++; } //Console.WriteLine(DateTime.Now.ToString("fff")); var tmp = -(Convert.ToInt32(dt.ToString("fff"))) + Convert.ToInt32(DateTime.Now.ToString("fff")); Console.WriteLine("Всего затрачено {0} ms", tmp); }); Thread th3 = new Thread(() => { for (int i = 0; i < N; i++) { Thread.Sleep(2); // Console.WriteLine("Thread 1"); data.y++; } }); th2.IsBackground = true; th3.IsBackground = true; th2.Start(); th3.Start(); Console.ReadLine(); }