Exemplo n.º 1
0
        public void IsCreateNewFileTest()
        {
            var newFileOutput  = CsvDownloadOutputSettings.Create(TabularOutputEncoding.UTF8, TabularOutputDestination.NewCsvFile);
            var newSheetOutput = CsvDownloadOutputSettings.Create(TabularOutputEncoding.SJIS, TabularOutputDestination.NewWorksheet);

            Assert.IsTrue(CsvDownloadParameters.Create(ticker, from, to, newFileOutput).IsCreateNewFile());
            Assert.IsFalse(CsvDownloadParameters.Create(ticker, from, to, newSheetOutput).IsCreateNewFile());
        }
Exemplo n.º 2
0
        public void IsUTF8EncodingTest()
        {
            var utf8Output = CsvDownloadOutputSettings.Create(TabularOutputEncoding.UTF8, TabularOutputDestination.NewCsvFile);
            var sjisOutput = CsvDownloadOutputSettings.Create(TabularOutputEncoding.SJIS, TabularOutputDestination.NewWorksheet);

            Assert.IsTrue(CsvDownloadParameters.Create(ticker, from, to, utf8Output).IsUTF8Encoding());
            Assert.IsFalse(CsvDownloadParameters.Create(ticker, from, to, sjisOutput).IsUTF8Encoding());
        }
Exemplo n.º 3
0
        public void BuildQuarterCsvWriterTest()
        {
            var parameters = CsvDownloadParameters.Create(ticker, from, to,
                                                          newFileSettting);
            var writer = quarterBuilder.Set(parameters).Build();

            Assert.IsInstanceOfType(writer, typeof(CsvFileTabularWriter <Quarter>));
        }
Exemplo n.º 4
0
        // If you want test worksheet, comment in
        // On GitHub Actions, we can't use Windows Office now
        // [TestMethod()]
        public void BuildQuarterWorkseetTest()
        {
            var parameters = CsvDownloadParameters.Create(ticker, from, to,
                                                          newSheetsetting);
            var writer = quarterBuilder.Set(parameters).Build();

            Assert.IsInstanceOfType(writer, typeof(WorksheetTabularWriter <Quarter>));
        }
 private void UpdateFormValues(CsvDownloadParameters parameters)
 {
     textTicker.Text       = parameters.Ticker;
     textFrom.Text         = parameters.Range.From.ToString();
     textTo.Text           = parameters.Range.To.ToString();
     radioCSV.Checked      = parameters.IsCreateNewFile();
     radioSheet.Checked    = !parameters.IsCreateNewFile();
     radioUTF8.Checked     = parameters.IsUTF8Encoding();
     radioShiftJIS.Checked = !parameters.IsUTF8Encoding();
 }
        public IEnumerable <Quarter> GetQuarters(CsvDownloadParameters parameters)
        {
            // set isConfigureAwait for performance
            // https://devblogs.microsoft.com/dotnet/configureawait-faq/#why-would-i-want-to-use-configureawaitfalse
            var quarters = PeriodRange <FiscalQuarterPeriod> .Slice(parameters.Range, 4)
                           .SelectMany
                               (r => processor.GetApiResources(DataTypeConfig.Quarter, parameters.Ticker, r.From, r.To, false, true)
                               ).Cast <Quarter>();

            return(quarters.Distinct().OrderBy(q => q.Period));
        }
        private CsvDownloadParameters CreateParametersFromFormValues()
        {
            var ticker      = textTicker.Text;
            var from        = FiscalQuarterPeriod.Parse(textFrom.Text);
            var to          = FiscalQuarterPeriod.Parse(textTo.Text);
            var encoding    = radioUTF8.Checked ? TabularOutputEncoding.UTF8 : TabularOutputEncoding.SJIS;
            var destination = radioCSV.Checked ? TabularOutputDestination.NewCsvFile
                : TabularOutputDestination.NewWorksheet;

            return(CsvDownloadParameters.Create(ticker, from, to, CsvDownloadOutputSettings.Create(encoding, destination)));
        }
Exemplo n.º 8
0
        public void CreateTest()
        {
            var outputParams = CsvDownloadOutputSettings.Create(TabularOutputEncoding.UTF8, TabularOutputDestination.NewCsvFile);

            var parameters = CsvDownloadParameters.Create(ticker, from, to,
                                                          outputParams);

            Assert.AreEqual(ticker, parameters.Ticker);
            Assert.AreEqual(from, parameters.Range.From);
            Assert.AreEqual(to, parameters.Range.To);

            Assert.ThrowsException <ValidationError>(() => CsvDownloadParameters.Create("aa", from, to, outputParams));
        }
        public void GetQuartersTest()
        {
            var ticker         = "6501";
            var from           = FiscalQuarterPeriod.Create(2020, 1);
            var to             = FiscalQuarterPeriod.Create(2020, 2);
            var outputSettings = CsvDownloadOutputSettings.Create(TabularOutputEncoding.SJIS, TabularOutputDestination.NewWorksheet);
            var parameters     = CsvDownloadParameters.Create(ticker, from, to, outputSettings);
            var quarters       = ApiResourceGetter.Create().GetQuarters(parameters).ToArray();
            var quarter2020Q1  = quarters[0];
            var quarter2020Q2  = quarters[1];

            Assert.AreEqual(2, quarters.Length);
            Assert.AreEqual(ticker, quarter2020Q1.Ticker);
            Assert.AreEqual(ticker, quarter2020Q2.Ticker);
            Assert.AreEqual(from, quarter2020Q1.Period);
            Assert.AreEqual(to, quarter2020Q2.Period);
        }
Exemplo n.º 10
0
        public void SaveAndLoadTest()
        {
            var ticker         = "1234";
            var from           = FiscalQuarterPeriod.Create(2021, 1);
            var to             = FiscalQuarterPeriod.Create(2022, 1);
            var outputSettings = CsvDownloadOutputSettings.Create(TabularOutputEncoding.SJIS, TabularOutputDestination.NewWorksheet);
            var newParams      = CsvDownloadParameters.Create(ticker, from, to, outputSettings);

            CsvDownloadDefaultParametersHandler.Save(newParams);
            var loaded = CsvDownloadDefaultParametersHandler.Load();

            Assert.AreEqual(ticker, loaded.Ticker);
            Assert.AreEqual(from, loaded.Range.From);
            Assert.AreEqual(to, loaded.Range.To);
            Assert.AreEqual(TabularOutputEncoding.SJIS, loaded.OutputSettings.Encoding);
            Assert.AreEqual(TabularOutputDestination.NewWorksheet
                            , loaded.OutputSettings.Destination);
        }
Exemplo n.º 11
0
 public TabularWriterBuilder <T> Set(CsvDownloadParameters parameters)
 {
     this.parameters = parameters;
     return(this);
 }