Exemplo n.º 1
0
        public static void Main( )
        {
            Console.Title = "Evo Bio 4";

            var v = new Variables
            {
                CooperatorQuantity = 10,
                DefectorQuantity   = 10,
                SdQuality          = 1,
                Y                          = .8,
                Relatedness                = .15,
                PercentileCutoff           = 10,
                Z                          = 1.96,
                MaxTimeSteps               = 5000,
                Runs                       = 10000,
                IncludeConfidenceIntervals = true
            };

            var strategyCollection = new StrategyCollection
            {
                Survival     = Survival.QualityProportional,
                Fitness      = Fitness.NonReproducingHave0Fitness,
                Reproduction = Reproduction.FitnessProportional,
                PostProcess  = PostProcess.DoNothing
            };

            Simulate <Iteration> (v, strategyCollection);
        }
Exemplo n.º 2
0
    public GenericStrategyExecutor <input, result> Get <input, result>(IEnumerable <IStrategy <input, result> > strategies)
    {
        var strategyCollection = new StrategyCollection <IStrategy <input, result> >(strategies);
        var strategyPattern    = new GenericStrategyExecutor <input, result>(strategyCollection);

        return(strategyPattern);
    }
Exemplo n.º 3
0
    public void SetCollectionShouldPassOnEmptyList()
    {
        var strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());

        var exception = Record.Exception(() => strategyCollection.SetCollection(new List <IInlineElementConverter>()));

        Assert.Null(exception);
    }
Exemplo n.º 4
0
    void SetCollectionShouldThrowErrorOnTypeWithNoAttribute()
    {
        var    strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());
        var    mockConverter      = new FakeConverterWithoutAttribute();
        object dummyObject        = new Object();

        Assert.Throws <StrategyMapperAttributeNotFoundException>(() =>
        {
            strategyCollection.SetCollection(new List <IInlineElementConverter>()
            {
                mockConverter
            });
        });
    }
Exemplo n.º 5
0
    public void SetCollectionShouldMapTypesToImplementations()
    {
        var    strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());
        var    mockConverter      = new FakeConverterWithAttribute();
        object dummyObject        = new Object();

        strategyCollection.SetCollection(new List <IInlineElementConverter>()
        {
            mockConverter
        });

        var strategy = strategyCollection.GetStrategyForType(dummyObject.GetType());

        Assert.IsType(mockConverter.GetType(), strategy);
    }
Exemplo n.º 6
0
    void GetStrategyShouldThrowExceptionWhenTypeIsNotFound()
    {
        var    strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());
        var    mockConverter      = new FakeConverterWithAttribute();
        object dummyObject        = new Object();

        strategyCollection.SetCollection(new List <IInlineElementConverter>()
        {
            mockConverter
        });

        Assert.Throws <StrategyNotFoundException>(() =>
        {
            var strategy = strategyCollection.GetStrategyForType(mockConverter.GetType());
        });
    }
Exemplo n.º 7
0
        public void AddStrategy()
        {
            if (string.IsNullOrEmpty(Name))
            {
                return;
            }

            // Save to DB
            using (var context = new QTSDbContext())
            {
                var strategy = new EntityFramework.Strategy();
                strategy.Name = Name;
                strategy.Type = Type;
                context.Strategies.Add(strategy);
                context.SaveChanges();

                StrategyCollection.Add(strategy);
                _events.PublishOnUIThread(new ModelEvents(new List <object>(new
                                                                            object[] { "Add strategy to DB: name = " + Name })));
            }
        }
Exemplo n.º 8
0
    void SetCollectionShouldFailOnNullList()
    {
        var strategyCollection = new StrategyCollection <IInlineElementConverter>(new List <IInlineElementConverter>());

        Assert.Throws <ArgumentNullException>(() => strategyCollection.SetCollection(null));
    }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new <see cref="Strategies_t"/> instance.
 /// </summary>
 public Strategies_t()
 {
     _strategies = new StrategyCollection(this);
 }
Exemplo n.º 10
0
 public GenericStrategyExecutor(StrategyCollection <IStrategy <result, input> > strategies)
 {
     this.strategies = strategies;
 }