public void TransformationExceptionConstructorErrorMessageInnerExceptionTest()
        {
            var exception = new TransformationException(ErrorMessage, InnerException);

            Assert.AreEqual(exception.Message, ErrorMessage);
            Assert.AreEqual(exception.InnerException, InnerException);
        }
        public void TransformationExceptionConstructorErrorMessageTransformTypeSourceValueTest()
        {
            var exception = new TransformationException(ErrorMessage, TransformType, this);

            Assert.AreEqual(exception.Message, ErrorMessage);
            Assert.AreEqual(exception.SourceValue, this);
            Assert.AreEqual(exception.TransformType, TransformType);
        }
        public void WrapsExceptionInTransformExceptionNullTransformer()
        {
            TransformationException thrownEx = null;

            try
            {
                new TransformationService <string, bool>(null).Transform(null);
            }
            catch (TransformationException tex)
            {
                thrownEx = tex;
            }
            Assert.IsInstanceOfType(thrownEx, typeof(TransformationException));
        }
コード例 #4
0
        public void WrapsExceptionInTransformException()
        {
            TransformationException thrownEx = null;

            try
            {
                new TestTransformer <string, bool>(str => { throw GeneralException; }).Transform(bool.TrueString);
            }
            catch (TransformationException tex)
            {
                thrownEx = tex;
            }
            Assert.IsInstanceOfType(thrownEx, typeof(TransformationException));
            Assert.AreEqual(GeneralException, thrownEx.InnerException);
        }
コード例 #5
0
        public void RethrowsTransformException()
        {
            TransformationException thrownEx = null;

            try
            {
                new TestTransformer <string, bool>(str => { throw TransformationException; }).Transform(bool.TrueString);
            }
            catch (TransformationException tex)
            {
                thrownEx = tex;
            }

            Assert.AreEqual(TransformationException, thrownEx);
        }
        public void RethrowsTransformException()
        {
            TransformationException thrownEx = null;

            try
            {
                TransformerMock.Setup(transform => transform.Transform(null)).Throws(TransformationException);
                TransformationService.Transform(null);
            }
            catch (TransformationException tex)
            {
                thrownEx = tex;
            }
            Assert.AreEqual(TransformationException, thrownEx);
            TransformerMock.Verify(transform => transform.Transform(null), Times.Once);
            TransformerMock.VerifyNoOtherCalls();
            TransformerMock.Reset();
        }
        public void WrapsExceptionInTransformException()
        {
            TransformationException thrownEx = null;

            try
            {
                TransformerMock.Setup(transform => transform.Transform(null)).Throws(GeneralException);
                TransformationService.Transform(null);
            }
            catch (TransformationException tex)
            {
                thrownEx = tex;
            }
            Assert.IsInstanceOfType(thrownEx, typeof(TransformationException));
            Assert.AreEqual(GeneralException, thrownEx.InnerException);
            TransformerMock.Verify(transform => transform.Transform(null), Times.Once);
            TransformerMock.VerifyNoOtherCalls();
            TransformerMock.Reset();
        }
コード例 #8
0
        public void Update(Action <TValue> inplace)
        {
            if (!HasPrevious)
            {
                ReplaceBy(toCopying(inplace));
                return;
            }

            try
            {
                inplace(Result);
            }
            catch (Exception ex)
            {
                TransformationException?.Invoke(ex);
                Result = restoreCurrent();
                return;
            }

            _copying.Add(null);
            _inplace.Add(inplace);
        }
コード例 #9
0
        public void ReplaceBy(Func <TValue, TValue> copying)
        {
            TValue transformed;

            try
            {
                transformed = copying(Result);
            }
            catch (Exception ex)
            {
                TransformationException?.Invoke(ex);
                return;
            }

            if (transformed.Equals(Result))
            {
                return;
            }

            _values.Add(transformed);
            _copying.Add(copying);
            _inplace.Add(null);
        }
        public void TransformationExceptionConstructor()
        {
            var exception = new TransformationException();

            Assert.IsInstanceOfType(exception, typeof(TransformationException));
        }