Ejemplo n.º 1
0
        public void PersonConverterTest()
        {
            var inputter  = new Mock <IPersonInputter>();
            var parser    = new Mock <IPersonParser>();
            var outputter = new Mock <IPersonOutputter>();

            inputter
            .Setup(i => i.GetPersonData())
            .Returns(tmpStrArray);
            parser
            .Setup(p => p.ParseToPersonEntity(tmpStrArray))
            .Returns(tmpPersonArray);
            var converter = new PersonConverter(inputter.Object, parser.Object, outputter.Object);

            converter.Convert();

            inputter.Verify(i => i.GetPersonData(), Times.Once);
            parser.Verify(p => p.ParseToPersonEntity(tmpStrArray), Times.Once);
            outputter.Verify(o => o.OutputPersons(tmpPersonArray), Times.Once);

            Assert.Throws <ArgumentNullException>(
                "inputter", () => new PersonConverter(null, parser.Object, outputter.Object));
            Assert.Throws <ArgumentNullException>(
                "parser", () => new PersonConverter(inputter.Object, null, outputter.Object));
            Assert.Throws <ArgumentNullException>(
                "outputter", () => new PersonConverter(inputter.Object, parser.Object, null));
        }