Esempio n. 1
0
        public virtual void TestSelector()
        {
            ConfigExtractor         extractor = GetTestConfig(false);
            RouletteSelector        selector  = new RouletteSelector(rnd);
            IList <OperationWeight> sList     = new List <OperationWeight>();
            Operation op = selector.Select(sList);

            NUnit.Framework.Assert.IsTrue(op == null);
            CreateOp cop = new CreateOp(extractor, rnd);

            sList.AddItem(new OperationWeight(cop, 1.0d));
            AppendOp aop = new AppendOp(extractor, rnd);

            sList.AddItem(new OperationWeight(aop, 0.01d));
            op = selector.Select(sList);
            NUnit.Framework.Assert.IsTrue(op == cop);
        }
Esempio n. 2
0
        /// <summary>Gets an operation instance (cached) for a given operation type</summary>
        /// <param name="type">the operation type to fetch for</param>
        /// <returns>Operation operation instance or null if it can not be fetched.</returns>
        internal virtual Operation GetOperation(Constants.OperationType type)
        {
            Operation op = typedOperations[type];

            if (op != null)
            {
                return(op);
            }
            switch (type)
            {
            case Constants.OperationType.Read:
            {
                op = new ReadOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Ls:
            {
                op = new ListOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Mkdir:
            {
                op = new MkdirOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Append:
            {
                op = new AppendOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Rename:
            {
                op = new RenameOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Delete:
            {
                op = new DeleteOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Create:
            {
                op = new CreateOp(this.config, rnd);
                break;
            }

            case Constants.OperationType.Truncate:
            {
                op = new TruncateOp(this.config, rnd);
                break;
            }
            }
            typedOperations[type] = op;
            return(op);
        }