예제 #1
0
        public void Handle_Worker_Fallback()
        {
            // Act
            SomeWorker worker;
            bool       baseExceptionWorksFlag, finallyWorksFlag;
            string     result;

            // Action
            result = null;
            baseExceptionWorksFlag = false;
            worker = new SomeWorker();
            try
            {
                worker.ExecuteDirty();
            }
            catch (FallbackException fex) when(fex.InternalData != null)
            {
                result = (string)fex.InternalData;
            }
            catch (Exception)
            {
                baseExceptionWorksFlag = true;
            }
            finally
            {
                finallyWorksFlag = true;
            }

            // Assert
            Assert.NotNull(result);
            Assert.False(baseExceptionWorksFlag);
            Assert.True(finallyWorksFlag);
        }
예제 #2
0
        public void Handle_Worker_Exception()
        {
            // Act
            SomeWorker worker;
            bool       baseExceptionWorksFlag, finallyWorksFlag;
            string     result;

            // Action
            result = null;
            baseExceptionWorksFlag = false;
            worker = new SomeWorker();
            try
            {
                result = worker.ExecuteAtomic();
            }
            catch (Exception)
            {
                baseExceptionWorksFlag = true;
            }
            finally
            {
                finallyWorksFlag = true;
            }

            // Assert
            Assert.True(baseExceptionWorksFlag);
            Assert.True(finallyWorksFlag);
            Assert.Null(result);
        }
예제 #3
0
        public Task DoStuffAsync()
        {
            var worker = new SomeWorker(_ec);

            return(worker.WorkAsync());
        }
예제 #4
0
 public Samples()
 {
     worker = new SomeWorker();
 }