Пример #1
0
        private async Task VerifyGetThrowsArgumentOutOfRangeException(int index)
        {
            ArgumentOutOfRangeException expectedException = null;

            try
            {
                await _repository.Get(WarId, index);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                expectedException = ex;
            }
            expectedException.Should().NotBeNull();
        }
Пример #2
0
        public void it_should_throw_when_provided_type_is_not_of_required_provider_base_type()
        {
            ArgumentOutOfRangeException exception = null;

            try
            {
                ((UrsaConfigurationSection)ConfigurationManager.GetSection(UrsaConfigurationSection.ConfigurationSectionGroupName)).GetProvider <IConverterProvider>(typeof(object));
            }
            catch (ArgumentOutOfRangeException error)
            {
                exception = error;
            }

            exception.Should().NotBeNull();
        }
        public void NonExistingSheetIndexThrowsMeaningfulError()
        {
            var testFileLocation                  = TestHelper.TestsheetPath("TestSpreadsheet1.xlsx");
            var lightWeightExcelReader            = new ExcelReader(testFileLocation);
            ArgumentOutOfRangeException exception = null;

            try
            {
                var sheet = lightWeightExcelReader[999];
                var test  = sheet["A1"];
            }
            catch (Exception e)
            {
                exception = e as ArgumentOutOfRangeException;
            }

            exception.Should().NotBe(null);
            exception.Message.Should().StartWith("Sheet with zero-based index 999 was not found in the workbook. Workbook contains 10 sheets");
        }
        public void NonExistingSheetThrowsMeaningfulError()
        {
            var testFileLocation                  = TestHelper.TestsheetPath("TestSpreadsheet1.xlsx");
            var lightWeightExcelReader            = new ExcelReader(testFileLocation);
            ArgumentOutOfRangeException exception = null;

            try
            {
                var sheet = lightWeightExcelReader["ThisSheetDoesNotExist"];
                var test  = sheet["A1"];
            }
            catch (Exception e)
            {
                exception = e as ArgumentOutOfRangeException;
            }

            exception.Should().NotBe(null);
            exception.Message.Should().StartWith("Sheet with name 'ThisSheetDoesNotExist' was not found in the workbook");
        }