Exemplo n.º 1
0
        public void HasResourcesTrueOnEmpty()
        {
            var player = new Player("Bob");
            bool result = player.HasResources(new MaterialType[] { });

            Assert.True(result);
        }
Exemplo n.º 2
0
        public void RemoveResourcesNotInInventoryException(MaterialType[] playerResources, MaterialType[] removeResources)
        {
            var player = new Player("Henk");

            foreach (var resource in playerResources)
            {
                var mock = new Mock<IRawMaterial>();
                mock.Setup(m => m.Type).Returns(resource);
                player.AddResources(mock.Object);
            }

            Assert.Throws<InvalidOperationException>(() => player.TakeResources(removeResources));
            Assert.True(player.HasResources(playerResources)); //assert nothing gets removed when failing
        }
Exemplo n.º 3
0
        public void HasResourceFalseOnNull()
        {
            var player = new Player("Bob");
            bool result = player.HasResources(null);

            Assert.False(result);
        }
Exemplo n.º 4
0
        public void HasResourcesTest(MaterialType[] current, MaterialType[] requested, bool expected)
        {
            var player = new Player("Bob");
            foreach (var material in current)
            {
                var mock = new Mock<IRawMaterial>();
                mock.Setup(m => m.Type).Returns(material);
                player.AddResources(mock.Object);
            }
            bool result = player.HasResources(requested);

            Assert.True(expected == result, $"Expected: {expected} != result {result}.\nCurrent:{string.Join(", ", current)}\nRequested:{string.Join(", ", requested)}");
        }