Beispiel #1
0
        public void Retrieve_NoParameters_ReturnsIDataReader()
        {
            _command.Setup(x => x.ExecuteReader()).Returns(new Mock <IDataReader>().Object);
            var commandText = "test";

            var result = _data.Retrieve(commandText);

            Assert.IsAssignableFrom <IDataReader>(result);
            _command.VerifySet(x => x.CommandText = commandText, Times.Once());
            _command.VerifySet(x => x.CommandType = CommandType.StoredProcedure, Times.Never());
            _command.Verify(x => x.CreateParameter(), Times.Never());
            _command.Verify(x => x.Parameters.Add(It.IsAny <IDbDataParameter>()), Times.Never());
            _connection.Verify(x => x.Open(), Times.Once());
            _command.Verify(x => x.ExecuteReader(), Times.Once());
        }