public void NewSequenctArgument1() { MySequence sequence = new MySequence(""); // 由于上面的代码发生了异常,下面这句应该执行不到。 Assert.Fail("本测试应该触发一个异常。"); }
public void NewSequenctArgument9() { // 后面数字小于零的. MySequence sequence = new MySequence('A', -1); // 由于上面的代码发生了异常,下面这句应该执行不到。 Assert.Fail("本测试应该触发一个异常。"); }
public void NewSequenctArgument7() { // 字母 O 开头的,不允许. MySequence sequence = new MySequence('O', 0); // 由于上面的代码发生了异常,下面这句应该执行不到。 Assert.Fail("本测试应该触发一个异常。"); }
public void PlusOverflow() { // Z98 + 2 溢出. sequence = new MySequence("Z99"); sequence = sequence + 2; // 由于上面的代码发生了异常,下面这句应该执行不到。 Assert.Fail("本测试应该触发一个异常。"); }
public void NewSequenct() { // 首先测试默认的构造函数. 结果应当等价于 001。 Assert.AreEqual("001", sequence.ToString()); // 再测试 几种不同的构造函数的方式,能否得出相同的序列号. sequence = new MySequence('0', 1); Assert.AreEqual("001", sequence.ToString()); }
public void MinusMinusOverflow() { // 000-- 溢出. sequence = new MySequence("000"); sequence--; // 由于上面的代码发生了异常,下面这句应该执行不到。 Assert.Fail("本测试应该触发一个异常。"); }
static void Main(string[] args) { MySequence mySeq = new MySequence(); Console.WriteLine(mySeq.ToString()); Console.WriteLine("不变模式暂无太多例子可供演示......"); Console.ReadLine(); }
public void TestFixtureSetUp() { // TestFixtureSetUp 意味着整个测试过程,本方法只执行一次. // 初始化最小序列号 minSequenct = new MySequence('0', 1); // 初始化最大序列号 maxSequenct = new MySequence('Z', 99); }
public static void Main() { MySequence ob = new MySequence(); //ob.MyProp = 5; Console.WriteLine("Original value of ob.MyProp: " + ob.MyProp); ob.increaseSequence(); Console.WriteLine("Value of ob.MyProp after increment: " + ob.MyProp); }
public void PlusAndPlusPlus() { sequence = new MySequence("000"); MySequence seq2 = new MySequence("000"); // 遍历,确保每一个 ++ 操作的结果, 与 +1 的结果是一致的. while (sequence != maxSequenct) { sequence++; seq2 = seq2 + 1; Assert.AreEqual(sequence, seq2); } }
public void MinusMinus() { // Z99-- = Z98 sequence = new MySequence("Z99"); sequence--; Assert.AreEqual("Z98", sequence.ToString()); // P00-- = N99 ( 因为字母 O 被排除掉了) sequence = new MySequence("P00"); sequence--; Assert.AreEqual("N99", sequence.ToString()); // 001-- = 000 sequence = new MySequence("001"); sequence--; Assert.AreEqual("000", sequence.ToString()); }
public void PlusPlus() { // 001++ = 002 sequence++; // 001++ 后,结果为 002 Assert.AreEqual("002", sequence.ToString()); // 测试 999++ = A00 sequence = new MySequence("999"); sequence++; Assert.AreEqual("A00", sequence.ToString()); // 测试 N99++ = P00 ( 因为字母 O 被排除掉了) sequence = new MySequence("N99"); sequence++; Assert.AreEqual("P00", sequence.ToString()); }
// Use this for initialization void Start() { //selektor1 = new MySelector(verhalten1); parallel1 = new MyParallelTask(verhalten1); untilfail1 = new MyUntilFail(parallel1); selector1 = new MySelector(untilfail1); sequence1 = new MySequence(selector1); collectTrash1 = new CollectTrash(collector.GetComponent <Rigidbody>(), collector.GetComponent <Transform>(), verhalten1, parallel1); seek2 = new Seek(dropper.GetComponent <Rigidbody>(), dropper.GetComponent <Transform>(), ladeStation.GetComponent <Transform>(), verhalten1, selector1); drop1 = new Drop(dropper.GetComponent <Rigidbody>(), dropper.GetComponent <Transform>(), trash, verhalten1, sequence1); //wander1 = new Wander(target.GetComponent<Rigidbody>(),target.GetComponent<Transform>(), verhalten1, sequence1); seek1 = new Seek(seeker.GetComponent <Rigidbody>(), seeker.GetComponent <Transform>(), dropper.GetComponent <Transform>(), verhalten1, sequence1); saveWanderer1 = new SaveWanderer(seeker.GetComponent <Rigidbody>(), seeker.GetComponent <Transform>(), dropper.GetComponent <Rigidbody>(), dropper.GetComponent <Transform>(), new Vector3(0, 0.6f, 0), verhalten1, sequence1); verhalten1.startZwei(); }
public void TryParse() { // 测试 TryParse 的正确性. bool tyrResult = MySequence.TryParse("", out sequence); // 空白字符串. TryParse 结果应该 无效. Assert.IsFalse(tyrResult); // 测试 TryParse 的正确性. tyrResult = MySequence.TryParse("1", out sequence); // 长度为1的字符串. TryParse 结果应该 无效. Assert.IsFalse(tyrResult); // TODO // 需要 TryParse 的可能性太多 // 传入的参数,与返回结果,放在一个 Access 或者 Excel 表格里面处理更好一些. }
public void Plus() { // 001 + 100 = 101 sequence = new MySequence("001"); sequence = sequence + 100; Assert.AreEqual("101", sequence.ToString()); // A01 + 200 = C01 sequence = new MySequence("A01"); sequence = sequence + 200; Assert.AreEqual("C01", sequence.ToString()); // N01 + 123 = P24 sequence = new MySequence("N01"); sequence = sequence + 123; Assert.AreEqual("P24", sequence.ToString()); }
static void Main(string[] args) { do { try { Console.Clear(); Random rnd = new Random(); int n; Console.Write("Enter x = "); int.TryParse(Console.ReadLine(), out n); List <TestClass> Tarr = new List <TestClass>(); for (int i = 0; i < n; i++) { Tarr.Add(new TestClass(rnd.Next(-5, 5))); } MySequence <TestClass> arr = new MySequence <TestClass>(Tarr); Console.WriteLine("Count of lokal minimum = {0}", arr.CountLocalMinimun()); if (arr.isAllEqual()) { Console.WriteLine("All equal"); } else { for (int i = 0; ; i++) { Console.WriteLine(arr[i]); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (Console.ReadKey().Key != ConsoleKey.Escape); }
static void Main(string[] args) { do { int N = -1; Console.WriteLine("Введите N: "); while (!int.TryParse(Console.ReadLine(), out N) || !(N > 0 && N <= 1000)) { Console.WriteLine("Число введено неверно!\nВведите N: "); } List <TestClass> seq = new List <TestClass>(); for (int i = 0; i < N; ++i) { TestClass testClass = new TestClass(); testClass.X = rnd.Next(-5, 6); seq.Add(testClass); } MySequence <TestClass> mySequence = new MySequence <TestClass>(seq); Console.WriteLine("Количество локальных минимумов: " + mySequence.CountLocalMinimum()); if (!mySequence.IsAllEqual) { try { int i = 0; while (true) { Console.WriteLine(mySequence[i].X); i += 2; } } catch (IndexOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { Console.WriteLine("Все элементы равны"); } MySequence <TestClass> mySequence2 = null; try { mySequence2 = new MySequence <TestClass>(null); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { int i = 0; while (true) { Console.WriteLine(mySequence2[i].X); i += 2; } } catch (IndexOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Нажмите ESC для выхода из программы"); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }