Ejemplo n.º 1
0
        public void FilterDeckListTest006_FilterByClassAndDeckType()
        {
            DeckClass classFilter     = DeckClass.Mage;
            var       filteredClasses = new ObservableCollection <DeckClass>(new List <DeckClass>()
            {
                classFilter
            });

            List <DeckType> typeFilter = new List <DeckType>()
            {
                DeckType.SoloArena
            };
            var filteredTypes = new ObservableCollection <DeckType>(typeFilter);

            int expectedCount = 2;

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                filteredTypes,
                false,
                false,
                classFilter,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.AreEqual(classFilter, result.ToList()[0].Class);
            Assert.AreEqual(classFilter, result.ToList()[1].Class);
            Assert.AreEqual(typeFilter[0], result.ToList()[0].Type);
            Assert.AreEqual(typeFilter[0], result.ToList()[1].Type);
        }
Ejemplo n.º 2
0
        public void FilterDeckListTest003_FilterByTwoAttributes()
        {
            List <DeckAttribute> filterAttrib = new List <DeckAttribute>()
            {
                DeckAttribute.Strength, DeckAttribute.Endurance
            };

            DeckClass?selectedClass   = null;
            var       filteredClasses = new ObservableCollection <DeckClass>(
                Utils.ClassAttributesHelper.FindClassByAttribute(filterAttrib)
                );

            Mock <IDeckTypeSelectorViewModel> typeSelector = GetFullTypeFilter();

            int expectedCount = 0 + //none inrandom data
                                1;  //one for every class

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                null,
                false,
                false,
                selectedClass,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.IsTrue(result.All(r => { return(Utils.ClassAttributesHelper.Classes[r.Class.Value].Contains(filterAttrib[0])); }));
        }
Ejemplo n.º 3
0
        public void FilterDeckListTest002_FilterByOneAttribute()
        {
            DeckAttribute filterAttrib    = DeckAttribute.Strength;
            DeckClass?    selectedClass   = null;
            var           filteredClasses = new ObservableCollection <DeckClass>(
                ClassAttributesHelper.FindClassByAttribute(filterAttrib)
                );

            Mock <IDeckTypeSelectorViewModel> typeSelector = GetFullTypeFilter();

            int expectedCount = 3 + //random data - archer i battlemage y strength
                                5;  //one for every class

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                null,
                false,
                false,
                selectedClass,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.IsTrue(result.All(r => { return(Utils.ClassAttributesHelper.Classes[r.Class.Value].Contains(filterAttrib)); }));
        }
Ejemplo n.º 4
0
        public void FilterDeckListTest001_FilterByClass()
        {
            DeckClass selectedClass   = DeckClass.Mage;
            var       filteredClasses = new ObservableCollection <DeckClass>(new List <DeckClass>()
            {
                selectedClass
            });

            int expectedCount = 3;

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                null,
                false,
                false,
                selectedClass,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.AreEqual(selectedClass, result.ToList()[0].Class);
            Assert.AreEqual(selectedClass, result.ToList()[1].Class);
            Assert.AreEqual(selectedClass, result.ToList()[2].Class);
        }
Ejemplo n.º 5
0
        public void FilterDeckListTest004_ClearFilters()
        {
            DeckClass?selectedClass   = null;
            var       filteredClasses = new ObservableCollection <DeckClass>(
                Utils.ClassAttributesHelper.FindClassByAttribute(DeckAttribute.Neutral)
                );

            Mock <IDeckTypeSelectorViewModel> typeSelector = GetFullTypeFilter();

            int expectedCount = DeckBase.Count;

            DeckListViewModel model = new DeckListViewModel();


            //do first filter - not intrested
            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                null,
                false,
                false,
                selectedClass,
                filteredClasses,
                null);

            //model is norw filyred
            Assert.AreNotEqual(expectedCount, result.Count());

            //reset filters - class selector returns all clases
            filteredClasses = new ObservableCollection <DeckClass>(
                Utils.ClassAttributesHelper.Classes.Keys
                );

            result = model.FilterDeckList(
                DeckBase,
                null,
                false,
                true,
                selectedClass,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
        }
Ejemplo n.º 6
0
        public void FilterDeckListTest007_HideCompletedVersusArenaRuns()
        {
            DeckClass classFilter     = DeckClass.Mage;
            var       selectedClass   = classFilter;
            var       filteredClasses = new ObservableCollection <DeckClass>(new List <DeckClass>()
            {
                classFilter
            });

            List <DeckType> typeFilter = new List <DeckType>()
            {
                DeckType.VersusArena
            };
            var filteredTypes          = new ObservableCollection <DeckType>(typeFilter);
            var showCompletedArenaRuns = false;

            Mock <ITracker>        tracker        = new Mock <ITracker>();
            Mock <ITrackerFactory> trackerFactory = new Mock <ITrackerFactory>();

            trackerFactory.Setup(tf => tf.GetNewGuid()).Returns(() => Guid.NewGuid());
            trackerFactory.Setup(tf => tf.GetTracker()).Returns(tracker.Object);
            trackerFactory.Setup(tf => tf.GetService <IDeckService>()).Returns(new DeckService(trackerFactory.Object));


            Deck deckToShow = new Deck(trackerFactory.Object)
            {
                Type = DeckType.VersusArena, Class = classFilter
            };
            Deck deckToHide = new Deck(trackerFactory.Object)
            {
                Type = DeckType.VersusArena, Class = classFilter
            };

            tracker.Setup(t => t.Games).Returns(
                new ObservableCollection <DataModel.Game>(
                    GenerateGamesList(deckToShow, 2, 2).Union(GenerateGamesList(deckToHide, 7, 2))
                    ));

            int expectedCount = 1;

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                new Deck[] { deckToShow, deckToHide },
                filteredTypes,
                showCompletedArenaRuns,
                false,
                selectedClass,
                filteredClasses,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.AreEqual(deckToShow.DeckId, result.First().DeckId);
        }
Ejemplo n.º 7
0
        public void FilterDeckListTest010_FilterIncludeHiddenDecks()
        {
            List <DeckType> typeFilter = new List <DeckType>()
            {
                DeckType.Constructed
            };
            var filteredTypes = new ObservableCollection <DeckType>(typeFilter);

            int expectedCount = 23;

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                filteredTypes,
                false,
                true,
                null,
                null,
                null);

            Assert.AreEqual(expectedCount, result.Count());
        }
Ejemplo n.º 8
0
        public void FilterDeckListTest005_FilterByDeckType()
        {
            List <DeckType> typeFilter = new List <DeckType>()
            {
                DeckType.SoloArena
            };
            var filteredTypes = new ObservableCollection <DeckType>(typeFilter);

            int expectedCount = 3; //only in random data

            DeckListViewModel model = new DeckListViewModel();

            IEnumerable <Deck> result = model.FilterDeckList(
                DeckBase,
                filteredTypes,
                false,
                false,
                null,
                Utils.ClassAttributesHelper.Classes.Keys,
                null);

            Assert.AreEqual(expectedCount, result.Count());
            Assert.IsTrue(result.All(r => { return(typeFilter.Contains(r.Type)); }));
        }