示例#1
0
        public void UpdateNumberToSystem_HappyPathTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                textbox = new TextBox();
                calculatorOrchestrator.UpdateNumberToSystem(textbox, "1");
                Assert.AreEqual("1", textbox.Text);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
示例#2
0
        public void ExecuteCE_HappyPathTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                textbox = new TextBox();
                calculatorOrchestrator.ExecuteCE(textbox);
                Assert.AreEqual(string.Empty, textbox.Text);
                Assert.AreEqual(string.Empty, calculatorOrchestrator.input);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
示例#3
0
        public void UpdateOperation_HappyPathTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                textbox = new TextBox();
                calculatorOrchestrator.input = "10";
                calculatorOrchestrator.UpdateOperation(textbox, Operator.Add);
                Assert.AreEqual("", textbox.Text);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
示例#4
0
        public void ChangeSign_HappyPathTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                textbox = new TextBox();
                calculatorOrchestrator.input = "10";
                calculatorOrchestrator.ChangeSign(textbox);
                Assert.AreEqual("-10", textbox.Text);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
示例#5
0
        public void ComputeResultDivide_HappyPathTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                textbox = new TextBox();
                calculatorOrchestrator.UpdateNumberToSystem(textbox, "10");
                calculatorOrchestrator.UpdateOperation(textbox, Operator.Divide);
                calculatorOrchestrator.UpdateNumberToSystem(textbox, "2");

                calculatorOrchestrator.ComputeResult(textbox);
                Assert.AreEqual("5", textbox.Text);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
示例#6
0
        public void UpdateNumberToSystem_ExceptionsTest()
        {
            CalculatorOrchestrator calculatorOrchestrator = new CalculatorOrchestrator();
            TextBox textbox = null;
            Thread  t       = new Thread(() =>
            {
                try
                {
                    calculatorOrchestrator.UpdateNumberToSystem(textbox, "1");
                    Assert.Fail("Expected exception not thrown");
                }
                catch (Exception)
                {
                    Assert.IsTrue(true);
                }
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }