Ejemplo n.º 1
0
            public async Task DoesNotSwallowUnexpectedExceptions()
            {
                // Arrange
                var expected = new FormatException("Something!");

                _validationService
                .Setup(x => x.StartValidationProcessAsync(It.IsAny <NuGetPackage>(), It.IsAny <string[]>(), It.IsAny <Guid>()))
                .Throws(expected);

                // Act & Assert
                var actual = await Assert.ThrowsAsync(
                    expected.GetType(),
                    () => _target.StartValidationAsync(_validationRequest.Object));

                Assert.Same(expected, actual);

                _validationService.Verify(
                    x => x.StartValidationProcessAsync(
                        It.IsAny <NuGetPackage>(),
                        It.IsAny <string[]>(),
                        It.IsAny <Guid>()),
                    Times.Once);
                _validationAuditor.Verify(
                    x => x.ReadAuditAsync(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>()),
                    Times.Never);
            }
Ejemplo n.º 2
0
        public void Invalid_Price_Throws_Exception()
        {
            _repository.ProductsList = "Products_InvalidPrice.txt";
            FormatException formatExeption = Assert.Throws <FormatException>(() => { _repository.GetProducts(); });

            Assert.Equal(typeof(FormatException), formatExeption.GetType());
        }
Ejemplo n.º 3
0
        public void Invalid_SalePrice_Throws_Exception()
        {
            _repository.SalePriceList = "SalePriceList_InvalidPrice.txt";
            FormatException formatExeption = Assert.Throws <FormatException>(() => { _repository.GetSalePrices(); });

            Assert.Equal(typeof(FormatException), formatExeption.GetType());
        }
Ejemplo n.º 4
0
        public void TestParseStringToTimeSpanException()
        {
            FormatException ex = Assert.ThrowsException <FormatException>(() =>
                                                                          DateUtil.ParseStringToTimeSpan("12-25-56")
                                                                          );

            Assert.IsNotNull(ex);
            Assert.IsInstanceOfType(ex.GetType(), typeof(FormatException).GetType());
            Assert.AreEqual(ex.Message, "Erro ao converter hora para TimeSpan");
        }
Ejemplo n.º 5
0
        private static bool handleFormatException(FormatException ex, MethodBase Method)
        {
            Logging.Logger("ERROR:  MethodName=" + Method.Name + "  Type: " + ex.GetType().Name + "  #:" + ex.HResult + "  Message:" + ex.Message);
            switch (ex.HResult)
            {
            case -2146233033:
                return(true);

            default:
                UnHandledError(ex, ex.HResult, Method);
                break;
            }
            return(false);
        }