예제 #1
0
        public void Load()
        {
            List <AlgorithmSaveBase> algorithms = new List <AlgorithmSaveBase>
            {
                new GaleShapleyAlgorithmSave
                {
                    AlgorithmName = "galeshapley"
                },
                new GeneticAlgorithmSave
                {
                    AlgorithmName              = "genetic",
                    AbsoluteSelection          = _settings.AbsoluteSelection,
                    SelectionRate              = _settings.SelectionRate,
                    MutationChance             = _settings.MutationChance,
                    StablePairWeight           = _settings.StablePairWeight,
                    GroupHappinessWeight       = _settings.GroupHappinessWeight,
                    EgalitarianHappinessWeight = _settings.EgalitarianHappinessWeight,
                    Generations = _settings.Generations,
                    Size        = _settings.Size
                }
            };
            MockPersistence mockPersistence = new MockPersistence
            {
                MockData = new SaveData
                {
                    Algorithms = algorithms
                }
            };

            NewModel();

            _context.Persistence = mockPersistence;
            _context.Persistence.Load("");

            _model.Load();
            Assert.AreEqual(2, _context.Algorithms.Count());

            Assert.AreEqual("galeshapley", _context.Algorithms[0].Name);
            _visitor = new AlgorithmVisitor(null,
                                            () => Assert.Fail());
            _visitor.Visit(_context.Algorithms[0].Element);

            Assert.AreEqual("genetic", _context.Algorithms[1].Name);
            _visitorParam = new AlgorithmVisitorParam((x) => Assert.Fail(),
                                                      (x) =>
            {
                Assert.AreEqual(x.Settings.AbsoluteSelection, _settings.AbsoluteSelection);
                Assert.AreEqual(x.Settings.SelectionRate, _settings.SelectionRate);
                Assert.AreEqual(x.Settings.MutationChance, _settings.MutationChance);
                Assert.AreEqual(x.Settings.StablePairWeight, _settings.StablePairWeight);
                Assert.AreEqual(x.Settings.GroupHappinessWeight, _settings.GroupHappinessWeight);
                Assert.AreEqual(x.Settings.EgalitarianHappinessWeight, _settings.EgalitarianHappinessWeight);
                Assert.AreEqual(x.Settings.Generations, _settings.Generations);
                Assert.AreEqual(x.Settings.Size, _settings.Size);
            });
            _visitorParam.Visit(_context.Algorithms[1].Element);
        }
예제 #2
0
 public void Load()
 {
     _model.Load();
     RefreshPage();
 }