Пример #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();
 }