Exemplo n.º 1
0
        public void ensureSetInputValueSucceeds()
        {
            AlgorithmImpl alg = new AlgorithmImpl();

            alg.setInputValue(Input.valueOf("one", "range"), "1");
            Assert.Equal("1", alg.inputValues[0].value);
        }
Exemplo n.º 2
0
        public void ensureSetInputValuesFailsIfArgumentIsNull()
        {
            AlgorithmImpl alg    = new AlgorithmImpl();
            Action        action = () => alg.setInputValues(null);

            Assert.Throws <ArgumentNullException>(action);
        }
Exemplo n.º 3
0
        public void ensureSetInputValueFailsIfInputDoesNotExist()
        {
            AlgorithmImpl alg    = new AlgorithmImpl();
            Action        action = () => alg.setInputValue(Input.valueOf("three", "range"), "val");

            Assert.Throws <ArgumentException>(action);
        }
Exemplo n.º 4
0
        public void ensureSetInputValueFailsIfInputExistsButDoesNotSupportValue()
        {
            AlgorithmImpl alg    = new AlgorithmImpl();
            Action        action = () => alg.setInputValue(Input.valueOf("one", "range"), "2");

            Assert.Throws <ArgumentOutOfRangeException>(action);
        }
Exemplo n.º 5
0
        public void ensureReadyFails()
        {
            AlgorithmImpl alg = new AlgorithmImpl();

            alg.setInputValue(Input.valueOf("one", "range"), "1");
            Action action = () => alg.ready();

            Assert.Throws <ArgumentNullException>(action);
        }
Exemplo n.º 6
0
        public void ensureGetRequiredInputsSucceeds()
        {
            AlgorithmImpl alg    = new AlgorithmImpl();
            List <Input>  inputs = alg.getRequiredInputs();

            Assert.Equal(2, inputs.Count);
            Assert.Equal("one", inputs[0].name);
            Assert.Equal("two", inputs[1].name);
        }
Exemplo n.º 7
0
        public void ensureReadySucceeds()
        {
            Input         input1 = Input.valueOf("one", "number 1");
            Input         input2 = Input.valueOf("two", "number 2");
            AlgorithmImpl alg    = new AlgorithmImpl();
            Dictionary <Input, string> inputValues = new Dictionary <Input, string>();

            inputValues.Add(input1, "1");
            inputValues.Add(input2, "2");
            alg.setInputValues(inputValues);
            alg.ready();
            //this method does not need an assert
        }
Exemplo n.º 8
0
        public void ensureSetInputValuesSucceeds()
        {
            Input         input1 = Input.valueOf("one", "number 1");
            Input         input2 = Input.valueOf("two", "number 2");
            AlgorithmImpl alg    = new AlgorithmImpl();
            Dictionary <Input, string> inputValues = new Dictionary <Input, string>();

            inputValues.Add(input1, "1");
            inputValues.Add(input2, "2");
            alg.setInputValues(inputValues);
            Assert.Equal("1", alg.inputValues[0].value);
            Assert.Equal("2", alg.inputValues[1].value);
        }
Exemplo n.º 9
0
        public void ensureSetInputValuesFailsIfAtLeastOneInputIsInvalid()
        {
            Input         input1 = Input.valueOf("one", "number 1");
            Input         input2 = Input.valueOf("three", "number 3");
            AlgorithmImpl alg    = new AlgorithmImpl();
            Dictionary <Input, string> inputValues = new Dictionary <Input, string>();

            inputValues.Add(input1, "1");
            inputValues.Add(input2, "3");
            Action action = () => alg.setInputValues(inputValues);

            Assert.Throws <ArgumentException>(action);
        }