コード例 #1
0
        public void TestLocationChange()
        {
            // setup
            Tub     t  = new Tub("T403");
            Machine m1 = new Machine(1001);
            Machine m2 = new Machine(1002);

            // place the tub on m1
            t.Location = m1;
            Assert.IsTrue(m1.GetTubs().Contains(t));
            Assert.IsFalse(m2.GetTubs().Contains(t));
            // move the tub
            t.Location = m2;
            Assert.IsFalse(m1.GetTubs().Contains(t));
            Assert.IsTrue(m2.GetTubs().Contains(t));
        }
コード例 #2
0
        public void TestAddTub()
        {
            // setup
            Tub     t  = new Tub("T402");
            Machine m1 = new Machine(1);
            Machine m2 = new Machine(2);

            // place the tub on m1
            t.Location = m1;
            Assert.AreEqual(1, m1.GetTubs().Count);
            // move the tub by adding it to m2
            m2.AddTub(t);
            Assert.AreEqual(m2, t.Location);
            Assert.AreEqual(0, m1.GetTubs().Count);
            Assert.AreEqual(1, m2.GetTubs().Count);
        }
コード例 #3
0
        public void TestLocationChange()
        {
            // przygotowanie
            Tub     t  = new Tub("T403");
            Machine m1 = new Machine(1001);
            Machine m2 = new Machine(1002);

            // umieszczenie pojemnika przy m1
            t.Location = m1;
            Assertion.Assert(m1.GetTubs().Contains(t));
            Assertion.Assert(!m2.GetTubs().Contains(t));
            // przeniesienie pojemnika
            t.Location = m2;
            Assertion.Assert(!m1.GetTubs().Contains(t));
            Assertion.Assert(m2.GetTubs().Contains(t));
        }
コード例 #4
0
        public void TestAddTub()
        {
            // przygotowanie
            Tub     t  = new Tub("T402");
            Machine m1 = new Machine(1);
            Machine m2 = new Machine(2);

            // umieszczenie pojemnika przy m1
            t.Location = m1;
            Assertion.AssertEquals(1, m1.GetTubs().Count);
            // przeniesienie pojemnika poprzez dodanie go do m2
            m2.AddTub(t);
            Assertion.AssertEquals(m2, t.Location);
            Assertion.AssertEquals(0, m1.GetTubs().Count);
            Assertion.AssertEquals(1, m2.GetTubs().Count);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: AnHoa/DesignPattern
        static void Main(string[] args)
        {
            TubOwner a = new TubOwner();

            Tub t1 = a.getTubContext();

            t1.DisplayTheJOKE();

            int[] arr = { 3, 4, 3, 8, 2, 1, 7, 1, 5, 6, 8, 3 };

            int  curMax  = 2;
            int  tmp     = 2;
            bool tmpFlag = true;
            bool Flag    = arr[0] - arr[1] > 0 ? true : false;

            for (int i = 2; i < arr.Length; i++)
            {
                tmpFlag = arr[i - 1] - arr[i] > 0 ? true : false;
                if (tmpFlag != Flag)
                {
                    tmp  = tmp + 1;
                    Flag = tmpFlag;
                }
                else
                {
                    if (tmp > curMax)
                    {
                        curMax = tmp;
                    }
                    tmp = 2;
                }
                //Console.WriteLine(tmp);
            }
            if (tmp > curMax)
            {
                curMax = tmp;
            }
            Console.WriteLine(curMax);
        }