public void NormalUnifiedAndDefaultTest(string query, string[] eresult) { var us = new CssSelectorImpl(); var elements = us.Select(XElement.Parse(SAMPLE_HTML), query); var result = elements.Select(_ => _.ToString()).ToArray(); CollectionAssert.AreEquivalent(eresult, result); var ds = new DefaultSelector(); elements = ds.Select(XElement.Parse(SAMPLE_HTML), query); result = elements.Select(_ => _.ToString()).ToArray(); CollectionAssert.AreEquivalent(eresult, result); }
public void AddCreature_GetBestCreatures(int size, int seed) { //arrange NewBestCretureFoundEventDelegate <FakeCreature> newBestFound = (_, __) => { }; RatedCreature <FakeCreature> foreFather = new RatedCreature <FakeCreature>(new FakeCreature(-1), -1); DisposedCreaturesStore <FakeCreature> disposedCreatures = new DisposedCreaturesStore <FakeCreature>(); DefaultSelector <FakeCreature> selector = new DefaultSelector <FakeCreature>(newBestFound, foreFather, size, disposedCreatures); RandomEnum rndE = new RandomEnum(seed); List <RatedCreature <FakeCreature> > insertedCreatures = new List <RatedCreature <FakeCreature> >(); int limit = size * 10; insertedCreatures.Add(foreFather); foreach (var num in rndE) { if (--limit < 0) { break; } insertedCreatures.Add(new RatedCreature <FakeCreature>(new FakeCreature(num), num)); } //act foreach (var creature in insertedCreatures) { selector.AddCreature(creature); } //Assert insertedCreatures.Sort((x, y) => y.CompareTo(x)); var expected = insertedCreatures.Take(size).ToList(); var actual = (from cr in selector.GetSurvivingCreatures() orderby cr.FitnessValue descending select cr).ToList(); Assert.AreEqual(expected.Count, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.AreEqual(expected[i].FitnessValue, actual[i].FitnessValue); } }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ static ContentPresenter() { DataTemplate template; FrameworkElementFactory text; Binding binding; // Default template for strings when hosted in ContentPresener with RecognizesAccessKey=true template = new DataTemplate(); text = CreateAccessTextFactory(); text.SetValue(AccessText.TextProperty, new TemplateBindingExtension(ContentProperty)); template.VisualTree = text; template.Seal(); s_AccessTextTemplate = template; // Default template for strings template = new DataTemplate(); text = CreateTextBlockFactory(); text.SetValue(TextBlock.TextProperty, new TemplateBindingExtension(ContentProperty)); template.VisualTree = text; template.Seal(); s_StringTemplate = template; // Default template for XmlNodes template = new DataTemplate(); text = CreateTextBlockFactory(); binding = new Binding(); binding.XPath = "."; text.SetBinding(TextBlock.TextProperty, binding); template.VisualTree = text; template.Seal(); s_XmlNodeTemplate = template; // Default template for UIElements template = new UseContentTemplate(); template.Seal(); s_UIElementTemplate = template; // Default template for everything else template = new DefaultTemplate(); template.Seal(); s_DefaultTemplate = template; // Default template selector s_DefaultTemplateSelector = new DefaultSelector(); }
public void SetUp() { _selector = Fixture.Create <DefaultSelector>(); }