예제 #1
0
        public void FromEmptyDbReader_ExpectDefaultOfString()
        {
            _readerStub.Read().Returns(false);

            var sut    = new SingleResultOrDefaultCommandInvoker <string>(_serviceCommand);
            var result = sut.Invoke(_serviceManager);

            Assert.AreEqual(default(string), result);
        }
예제 #2
0
        public void FromDbReaderWithOneRecord_CompareResult_ExpectSame()
        {
            _readerStub.Read().Returns(true, false);
            _serviceCommand.MapResult(_readerStub).Returns(_returnedResult);

            var sut    = new SingleResultOrDefaultCommandInvoker <string>(_serviceCommand);
            var result = sut.Invoke(_serviceManager);

            Assert.AreEqual(_returnedResult, result);
        }
예제 #3
0
        public void FromDbReaderWithTwoRecords_ExpectException()
        {
            _readerStub.Read().Returns(true, true, false);
            _serviceCommand.MapResult(_readerStub).Returns(_returnedResult);

            var sut = new SingleResultOrDefaultCommandInvoker <string>(_serviceCommand);

            Assert.Throws <InvalidOperationException>(() =>
            {
                sut.Invoke(_serviceManager);
            });
        }