Exemplo n.º 1
0
        public void SideTextBoxesWorkWithMultipleKeystrokes()
        {
            var form = new TriangleInfoFormForTest();

            form.KeystrokeOnSideATextBox('0');
            form.KeystrokeOnSideATextBox('.');
            form.KeystrokeOnSideATextBox('1');
            form.KeystrokeOnSideATextBox('x');
            form.KeystrokeOnSideATextBox('5');

            form.KeystrokeOnSideBTextBox('2');
            form.KeystrokeOnSideBTextBox('5');
            form.KeystrokeOnSideBTextBox('.');
            form.KeystrokeOnSideBTextBox('.');
            form.KeystrokeOnSideBTextBox('1');

            form.KeystrokeOnSideCTextBox('1');
            form.KeystrokeOnSideCTextBox('0');
            form.KeystrokeOnSideCTextBox('0');
            form.KeystrokeOnSideCTextBox(' ');
            form.KeystrokeOnSideCTextBox('?');

            Assert.AreEqual("0.15", form.SideAText);
            Assert.AreEqual("25.1", form.SideBText);
            Assert.AreEqual("100", form.SideCText);
        }
Exemplo n.º 2
0
        public void MessageTextShowsInstructionsWhileAnyTextBoxesAreEmpty()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "1";
            form.SideCText = "2";

            Assert.AreEqual(form.MsgInstruction, form.MessageText);
        }
Exemplo n.º 3
0
        public void MessageTextShowsInstructionsAfterTextBoxIsCleared()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "1";
            form.SideBText = "2";
            form.SideCText = "3";
            form.SideAText = "";

            Assert.AreEqual(form.MsgInstruction, form.MessageText);
        }
Exemplo n.º 4
0
        public void SideTextBoxesDontAllowInvalidPastedInput()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "10x";
            form.SideBText = "10a1";
            form.SideCText = "3.1.4";

            Assert.AreEqual(string.Empty, form.SideAText);
            Assert.AreEqual(string.Empty, form.SideBText);
            Assert.AreEqual(string.Empty, form.SideCText);
        }
Exemplo n.º 5
0
        public void SideTextBoxesAllowValidPastedInput()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "0";
            form.SideBText = "200";
            form.SideCText = "3.14";

            Assert.AreEqual("0", form.SideAText);
            Assert.AreEqual("200", form.SideBText);
            Assert.AreEqual("3.14", form.SideCText);
        }
Exemplo n.º 6
0
        public void SideTextBoxesDontAllowAlphaInput()
        {
            var form = new TriangleInfoFormForTest();

            form.SideBText = "1";
            form.SideCText = "23";

            form.KeystrokeOnSideATextBox('a');
            form.KeystrokeOnSideBTextBox('b');
            form.KeystrokeOnSideCTextBox('c');

            Assert.AreEqual("", form.SideAText);
            Assert.AreEqual("1", form.SideBText);
            Assert.AreEqual("23", form.SideCText);
        }
Exemplo n.º 7
0
        public void SideTextBoxesAllowFirstDecimal()
        {
            var form = new TriangleInfoFormForTest();

            form.SideBText = "1";
            form.SideCText = "23";

            form.KeystrokeOnSideATextBox('.');
            form.KeystrokeOnSideBTextBox('.');
            form.KeystrokeOnSideCTextBox('.');

            Assert.AreEqual(".", form.SideAText);
            Assert.AreEqual("1.", form.SideBText);
            Assert.AreEqual("23.", form.SideCText);
        }
Exemplo n.º 8
0
        public void SideTextBoxesAllowNumericInput()
        {
            var form = new TriangleInfoFormForTest();

            form.SideBText = "1";
            form.SideCText = "23";

            form.KeystrokeOnSideATextBox('4');
            form.KeystrokeOnSideBTextBox('5');
            form.KeystrokeOnSideCTextBox('6');

            Assert.AreEqual("4", form.SideAText);
            Assert.AreEqual("15", form.SideBText);
            Assert.AreEqual("236", form.SideCText);
        }
Exemplo n.º 9
0
        public void SideTextBoxesDontAllowSecondDecimal()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = ".";
            form.SideBText = "0.1";
            form.SideCText = "2.34";

            form.KeystrokeOnSideATextBox('a');
            form.KeystrokeOnSideBTextBox('b');
            form.KeystrokeOnSideCTextBox('c');

            Assert.AreEqual(".", form.SideAText);
            Assert.AreEqual("0.1", form.SideBText);
            Assert.AreEqual("2.34", form.SideCText);
        }
Exemplo n.º 10
0
        public void MessageTextShowsValidTriangleMessageOnValidSideLengths()
        {
            var form = new TriangleInfoFormForTest();
            var info = new TriangleStats()
            {
                Angle = TriangleAngle.Acute,
                Type  = TriangleType.Equilateral
            };
            var expectedMsg = form.GetTriangleMessage(info);

            form.SideAText = "1";
            form.SideBText = "1";
            form.SideCText = "1";

            Assert.AreEqual(expectedMsg, form.MessageText);

            info = new TriangleStats()
            {
                Angle = TriangleAngle.Right,
                Type  = TriangleType.Scalene
            };
            expectedMsg = form.GetTriangleMessage(info);

            form.SideAText = "3";
            form.SideBText = "4";
            form.SideCText = "5";

            Assert.AreEqual(expectedMsg, form.MessageText);

            info = new TriangleStats()
            {
                Angle = TriangleAngle.Obtuse,
                Type  = TriangleType.Isosceles
            };
            expectedMsg = form.GetTriangleMessage(info);

            form.SideAText = "2";
            form.SideBText = "2";
            form.SideCText = "3";

            Assert.AreEqual(expectedMsg, form.MessageText);
        }
Exemplo n.º 11
0
        public void MessageTextShowsInvalidTriangleMessageOnInvalidSideLengths()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "1";
            form.SideBText = "1";
            form.SideCText = "100";

            Assert.AreEqual(form.MsgInvalidTriangle, form.MessageText);

            form.SideAText = "1";
            form.SideBText = "100";
            form.SideCText = "1";

            Assert.AreEqual(form.MsgInvalidTriangle, form.MessageText);

            form.SideAText = "100";
            form.SideBText = "1";
            form.SideCText = "1";

            Assert.AreEqual(form.MsgInvalidTriangle, form.MessageText);
        }
Exemplo n.º 12
0
        public void MessageTextShowsErrorOnInvalidPastedInput()
        {
            var form = new TriangleInfoFormForTest();

            form.SideAText = "1";
            form.SideBText = "2";
            form.SideCText = "x";

            Assert.AreEqual(form.MsgInvalidInput, form.MessageText);

            form.SideBText = "1";
            form.SideCText = "2";
            form.SideAText = "x";

            Assert.AreEqual(form.MsgInvalidInput, form.MessageText);

            form.SideCText = "1";
            form.SideAText = "2";
            form.SideBText = "x";

            Assert.AreEqual(form.MsgInvalidInput, form.MessageText);
        }
Exemplo n.º 13
0
        public void MessageTextStartsWithInstructions()
        {
            var form = new TriangleInfoFormForTest();

            Assert.AreEqual(form.MsgInstruction, form.MessageText);
        }