Ejemplo n.º 1
0
        private void OptionArraySelectDatabase()
        {
            //Arrange
            string keyword = "12";

            mockRepository.Setup(repo => repo.AnyByKeyword(keyword))
            .Returns(true);
            mockRepository.Setup(repo => repo.GetByKeyword(keyword))
            .Returns(GetOptionsArray);
            mockJson.Setup(p => p.GetJsonResult(It.IsAny <OptionsArrayJsonModel>()))
            .Returns(GetJsonResult());
            Char[] input = new Char[] { '1', '2' };
            mockValidate.Setup(p => p.Validate(input))
            .Returns((false, ""));
            mockOptionResult.Setup(p => p.GeOptionsSortArray(keyword))
            .Returns(GetListObject());
            MyOptionsArray myOptionsArray
                = new MyOptionsArray(mockRepository.Object, mockValidate.Object, mockJson.Object, mockOptionResult.Object);

            //Act
            var result = myOptionsArray.GetOptions(input);

            //Assert
            Assert.NotNull(result);
            Assert.IsType <string>(result);
        }
Ejemplo n.º 2
0
        private void OptionArrayValidateError()
        {
            //Arrange
            mockJson.Setup(p => p.GetJsonResult(It.IsAny <OptionsArrayJsonModel>()))
            .Returns(GetJsonNotValidResult());
            Char[] input = new Char[] { '1', '2' };
            mockValidate.Setup(p => p.Validate(input))
            .Returns((true, ""));
            MyOptionsArray myOptionsArray
                = new MyOptionsArray(mockRepository.Object, mockValidate.Object, mockJson.Object, mockOptionResult.Object);

            //Act
            var result = myOptionsArray.GetOptions(input);

            //Assert
            Assert.NotNull(result);
            Assert.IsType <string>(result);
        }