コード例 #1
0
    public void Multiple_scores_with_multiple_letters()
    {
        var input = new Dictionary <int, string[]>
        {
            [1] = new[] { "A", "E" },
            [2] = new[] { "D", "G" }
        };
        var expected = new Dictionary <string, int>
        {
            ["a"] = 1,
            ["d"] = 2,
            ["e"] = 1,
            ["g"] = 2
        };

        Assert.Equal(expected, Etl.Transform(input));
    }
コード例 #2
0
    public void Single_score_with_multiple_letters()
    {
        var input = new Dictionary <int, string[]>
        {
            [1] = new[] { "A", "E", "I", "O", "U" }
        };
        var expected = new Dictionary <string, int>
        {
            ["a"] = 1,
            ["e"] = 1,
            ["i"] = 1,
            ["o"] = 1,
            ["u"] = 1
        };

        Assert.Equal(expected, Etl.Transform(input));
    }
コード例 #3
0
ファイル: EtlTest.cs プロジェクト: mercy-merry/exercism
    public void Multiple_scores_with_differing_numbers_of_letters()
    {
        var input = new Dictionary <int, string[]>
        {
            [1]  = new[] { "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" },
            [2]  = new[] { "D", "G" },
            [3]  = new[] { "B", "C", "M", "P" },
            [4]  = new[] { "F", "H", "V", "W", "Y" },
            [5]  = new[] { "K" },
            [8]  = new[] { "J", "X" },
            [10] = new[] { "Q", "Z" }
        };
        var expected = new Dictionary <string, int>
        {
            ["a"] = 1,
            ["b"] = 3,
            ["c"] = 3,
            ["d"] = 2,
            ["e"] = 1,
            ["f"] = 4,
            ["g"] = 2,
            ["h"] = 4,
            ["i"] = 1,
            ["j"] = 8,
            ["k"] = 5,
            ["l"] = 1,
            ["m"] = 3,
            ["n"] = 1,
            ["o"] = 1,
            ["p"] = 3,
            ["q"] = 10,
            ["r"] = 1,
            ["s"] = 1,
            ["t"] = 1,
            ["u"] = 1,
            ["v"] = 4,
            ["w"] = 4,
            ["x"] = 8,
            ["y"] = 4,
            ["z"] = 10
        };

        Assert.Equal(expected, Etl.Transform(input));
    }
コード例 #4
0
ファイル: RavenConfiguration.cs プロジェクト: ikvm/ravendb
        public RavenConfiguration Initialize()
        {
            var settingsNames           = Settings.AsEnumerable().Select(pair => pair.Key).ToHashSet(StringComparer.OrdinalIgnoreCase);
            var serverWideSettingsNames = ServerWideSettings?.AsEnumerable().Select(pair => pair.Key).ToHashSet(StringComparer.OrdinalIgnoreCase);

            Http.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Embedded.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Server.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Core.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Replication.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Cluster.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Etl.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Queries.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Patching.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Logs.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Memory.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Storage.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Security.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Backup.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Indexing.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Monitoring.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Studio.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Databases.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            PerformanceHints.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Licensing.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Tombstones.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Subscriptions.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            TransactionMergerConfiguration.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Notifications.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Updates.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Migration.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);
            Integrations.Initialize(Settings, settingsNames, ServerWideSettings, serverWideSettingsNames, ResourceType, ResourceName);

            PostInit();

            Initialized = true;

            return(this);
        }
コード例 #5
0
ファイル: EtlTests.cs プロジェクト: fuksi/SievoAssignment
        public void Execute_ValidFilePathAndSortByStartDateAsc_WriteToOutputWithAscOrder()
        {
            // MockBehavior strict allows us to verify order of calls
            _sievoLoggerMock = new Mock <ISievoLogger>(MockBehavior.Strict);
            _target          = new Etl(_sievoLoggerMock.Object);

            // MockBehavior requires setup for all invocations
            // we'll need 9 invocations for the current test data
            _sievoLoggerMock.Setup(x => x.Info(It.IsAny <string>()));
            for (var i = 0; i < 8; i++)
            {
                _sievoLoggerMock.Setup(x => x.Info(It.IsAny <string[]>()));
            }

            var args = new string[] { "--file", _testDataPath, "--sortByStartDate" };

            _target.Execute(args);

            // Verify header row output to follow strict invovation order
            _sievoLoggerMock.Verify(x => x.Info(It.Is <string>(msg => msg.Contains("Project"))));

            // Verify the rest
            var expectedDatesInAscOrder = new List <string> {
                "2012-06-01",
                "2012-06-01",
                "2013-01-01",
                "2013-01-01",
                "2013-01-01",
                "2013-01-01",
                "2013-04-01",
                "2014-01-01",
            };

            expectedDatesInAscOrder.ForEach(dateStr =>
            {
                _sievoLoggerMock.Verify(x => x.Info(It.Is <string[]>(parts => string.Join(',', parts).Contains(dateStr))));
            });
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: reddaiahece/bo-utils
        static int Main(string[] args)
        {
            try{
                Console.WriteLine("");
                if (args.Length != 2)
                {
                    Console.WriteLine("Error: Number of argument is invalid !");
                    PrintHelper();
                    return((int)ExitCode.InvalidArguments);
                }

                string xmlFIlePath = args[0];
                string logFIlePath = args[1];

                if (!File.Exists(xmlFIlePath))
                {
                    Console.WriteLine("Error: Xml config file argument doesn't exist !");
                    PrintHelper();
                    return((int)ExitCode.InvalidArguments);
                }

                if (!Directory.Exists(Path.GetDirectoryName(logFIlePath)))
                {
                    Console.WriteLine("Error: The directory of the log file argument doesn't exist !");
                    PrintHelper();
                    return((int)ExitCode.InvalidArguments);
                }

                Logger logger;
                try{
                    logger = new Logger(args[1]);
                }catch (Exception ex) {
                    Console.WriteLine("Failed to create log file: " + ex.Message);
                    return((int)ExitCode.InvalidArguments);
                }

                Config config;
                try{
                    logger.Log("Read Xml configuration file " + xmlFIlePath);
                    config = Config.ParseFromXml(xmlFIlePath);
                }catch (Exception ex) {
                    logger.LogAndClose("Failed to parse Xml configuration file: " + ex.Message);
                    return((int)ExitCode.FailedToLoadXml);
                }

                List <IDataBase> databases = new List <IDataBase>();
                try{
                    foreach (Database db in config.Databases)
                    {
                        if (db.Type == "Firebird")
                        {
                            Firebird FbDb = new Firebird();
                            FbDb.Log += new Firebird.LogHandler(logger.Log);
                            FbDb.Initialise(db.Path, db.Username, db.Password, db.Multiload);
                            //FbDb.Initialise(db.Path, db.Username, Utils.XORcrypt(Utils.DecodeFrom64(db.Password)), db.Multiload);
                            databases.Add(FbDb);
                        }
                    }
                }catch (Exception ex) {
                    logger.LogAndClose("Failed to initialise the database: " + ex.Message);
                    return((int)ExitCode.FailedToSetDatabase);
                }

                Etl etl;
                try{
                    etl      = new Etl();
                    etl.Log += new Etl.LogHandler(logger.Log);
                    etl.Login(
                        config.WebService.WebServiceURL,
                        config.WebService.Domain,
                        config.WebService.Login,
                        //Utils.XORcrypt(Utils.DecodeFrom64(config.WebService.Password)),
                        config.WebService.Password,
                        config.WebService.AuthType
                        );
                }catch (Exception ex) {
                    logger.LogAndClose("Failed to login to Business Objects Web Service: " + ex.Message);
                    return((int)ExitCode.FailedToLogin);
                }
                try{
                    bool succeed = etl.ExtractTo(databases.ToArray());
                    etl.Logout();
                    if (succeed == true)
                    {
                        logger.LogAndClose("End of ETL. Data were successfully extrated ! ");
                    }
                    else
                    {
                        logger.LogAndClose("End of ETL. Some errors occured while extracting data ! ");
                    }
                    return((int)ExitCode.Succeed);
                }catch (Exception ex) {
                    logger.Log("Exception : " + ex.Message);
                    etl.Logout();
                    logger.LogAndClose("End of ETL. Failed to extract data ! ");
                    return((int)ExitCode.FailedToExtract);
                }
            }catch (Exception) {
                return((int)ExitCode.UnknownError);
            }
        }
コード例 #7
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Etl.WriteTplsToOrgTplAndOrg();
     MessageBox.Show("OK");
 }