示例#1
0
        public DungeonServiceCollectionEx_step4 WithSnapshots(Func <ISnapshotStore> factoryMethod, Action <SnapshotConfiguration> cfg)
        {
            var config = new SnapshotConfiguration();

            cfg(config);

            serviceCollection.AddSingleton(typeof(ISnapshotConfiguration), config);
            serviceCollection.AddScoped <ISnapshotManager>(c => new SnapshotManager(factoryMethod(), c.GetService <ISnapshotConfiguration>()));

            return(new DungeonServiceCollectionEx_step4(this));
        }
示例#2
0
        public void SnapTaskReturnTheGoodWhitelistBlacklistAndPeriodic()
        {
            string taskUuid  = "TaskUUID";
            string name      = "NAME";
            string tags      = "TAG1,TAG2";
            string periodic  = "5";
            string whitelist = "white*";
            string blacklist = "black*";

            string[]          argv = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "task", "snapshot", "--name", name, "--id", taskUuid, "--tags", tags, "--periodic", periodic, "--whitelist", whitelist, "--blacklist", blacklist };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is SnapshotConfiguration))
            {
                throw new Exception("return value is not SnapshotConfiguration ");
            }

            SnapshotConfiguration confset = (SnapshotConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Task);
            Assert.AreEqual(confset.Command, CommandApi.Snapshot);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, taskUuid);
            Assert.AreEqual(confset.SnapshotPeriodicSec.ToString(), periodic);
            Assert.AreEqual(confset.Whitelist, whitelist);
            Assert.AreEqual(confset.Blacklist, blacklist);

            argv     = new string[] { "task", "snapshot", "-n", name, "-i", taskUuid, "-t", tags, "--periodic", periodic, "--whitelist", whitelist, "--blacklist", blacklist };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is SnapshotConfiguration))
            {
                throw new Exception("return value is not SnapshotConfiguration ");
            }

            confset = (SnapshotConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Task);
            Assert.AreEqual(confset.Command, CommandApi.Snapshot);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, taskUuid);
            Assert.AreEqual(confset.SnapshotPeriodicSec.ToString(), periodic);
            Assert.AreEqual(confset.Whitelist, whitelist);
            Assert.AreEqual(confset.Blacklist, blacklist);
            commandLineParser.Dispose();
        }