Exemplo n.º 1
0
        public void Should_merge_2_suggestion_lists()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(5);
                suggestionList.Add(new Suggestion(Guid.NewGuid(), 1, 5));

                SuggestionList suggestionList2 = new SuggestionList(10);
                suggestionList2.Add(new Suggestion(Guid.NewGuid(), 1, 5));
                suggestionList2.Add(new Suggestion(Guid.NewGuid(), 2, 5));

                Assert.Less(0, suggestionList2.CompareTo(suggestionList));

                SuggestionList suggestionList3 = new SuggestionList(suggestionList, suggestionList2);

                Assert.AreEqual(15, suggestionList3.TotalSum);
                Assert.AreEqual(3, suggestionList3.Count);

                Assert.DoesNotThrow(() => new SuggestionList());
            }
        }
Exemplo n.º 2
0
        public void Should_merge_1_suggestion_list_with_connector()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(5);
                suggestionList.Add(new Suggestion(Guid.NewGuid(), 1, 5));

                Connector connector = new Connector(1, 5f);

                SuggestionList suggestionList3 = new SuggestionList(suggestionList, connector);

                Assert.AreEqual(10, suggestionList3.TotalSum);
                Assert.AreEqual(2, suggestionList3.Count);
            }
        }
Exemplo n.º 3
0
        public IEnumerable <Revelation> MakeSuggestion(Suggestion suggestion)
        {
            SuggestionList.Add(suggestion);
            var revelations    = new HashSet <Revelation>();
            var playersToCheck = new SortedSet <string>(AllPlayers);

            playersToCheck.Remove(suggestion.Suggester);
            playersToCheck.Remove(EnvelopePlayer);
            foreach (var player in playersToCheck)
            {
                ISet <Card> cards = new HashSet <Card>(PlayerHand(player));
                cards.IntersectWith(suggestion.SuggestedCards);
                if (cards.Count > 0)
                {
                    revelations.Add(new Revelation(player, null));
                }
            }

            return(revelations);
        }