예제 #1
0
        private GeoServiceException CreateAndLogServiceException(Exception exception)
        {
            var geoServiceException = new GeoServiceException(exception);

            this.loggingBroker.LogError(geoServiceException);

            return(geoServiceException);
        }
        public void ShouldThrowServiceExceptionOnRetrieveAllWhenServiceErrorOccursAndLogIt()
        {
            // given
            var serviceException            = new Exception();
            var expectedGeoServiceException = new GeoServiceException(serviceException);

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectAllGeos())
            .Throws(serviceException);

            // when . then
            Assert.Throws <GeoServiceException>(() => this.geoService.RetrieveAllGeos());

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectAllGeos(),
                                          Times.Once);

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedGeoServiceException))),
                                          Times.Once);
        }