示例#1
0
            public void DecreasesPileByOne()
            {
                var hand      = new Hand <TestCard>(TestCard.Factory(5));
                var priorSize = hand.Count;
                var taken     = hand.TakeAt(index: 3);

                Assert.NotNull(taken);
                Assert.Equal(expected: priorSize - 1, actual: hand.Count);
            }
示例#2
0
            public void ThrowsTooHighIndex()
            {
                var hand      = new Hand <TestCard>(TestCard.Factory(5));
                var priorSize = hand.Count;
                var ex        = Assert.Throws <ArgumentOutOfRangeException>(() => hand.TakeAt(index: hand.Count + 1));

                Assert.StartsWith(expectedStartString: ErrorStrings.RetrievalTooHighH, actualString: ex.Message);
                Assert.Equal(expected: "index", actual: ex.ParamName);
                Assert.Equal(expected: priorSize, actual: hand.Count);
            }
示例#3
0
            public void ThrowsOnNullFuncReturn()
            {
                var hand      = new Hand <TestCard>(TestCard.Factory(5));
                var priorSize = hand.Count;

                var ex = Assert.Throws <InvalidOperationException>(() => hand.Order(orderFunc: cards => null));

                Assert.Equal(expected: ErrorStrings.NewSequenceNull, actual: ex.Message);
                Assert.Equal(expected: priorSize, actual: hand.Count);
            }
示例#4
0
            public void ThrowsOnNullFunc()
            {
                var hand      = new Hand <TestCard>(TestCard.Factory(5));
                var priorSize = hand.Count;

                var ex = Assert.Throws <ArgumentNullException>(() => hand.Order(orderFunc: null));

                Assert.Equal(expected: "orderFunc", actual: ex.ParamName);
                Assert.Equal(expected: priorSize, actual: hand.Count);
            }
示例#5
0
            public void FuncDoesNotGiveDefaultArray()
            {
                const int init  = 0;
                const int added = 5;

                var  hand       = new Hand <TestCard>();
                bool funcCalled = false;

                hand.Order(orderFunc: cards =>
                {
                    funcCalled = true;
                    Assert.False(cards.IsDefault);
                    return(cards.Concat(TestCard.Factory(added)));
                });

                Assert.True(funcCalled);
                Assert.Equal(expected: init + added, actual: hand.Count);
            }