コード例 #1
0
        public void AddedStatCanBeFound()
        {
            // Assign
            var statsCollection = new StatsCollection(new List <IStatsProvider>()
            {
                new FakeStatsProvider()
            });

            // Act
            statsCollection.Prepare();
            statsCollection.Add("Default", new Stat(new FakeStatDefinition()
            {
                category = "Default", statName = "Agility"
            }));
            statsCollection.Add("Default2", new Stat(new FakeStatDefinition()
            {
                category = "Default", statName = "Agility"
            }));

            // Assert
            Assert.IsNotNull(statsCollection.Get("Default", "Agility"));
            Assert.IsNotNull(statsCollection.GetCategory("Default"));
            Assert.IsNotNull(statsCollection.GetCategory("Default2"));
            Assert.IsNotNull(statsCollection.Get("Default2", "Agility"));
        }
コード例 #2
0
        public void FindingStatThatDoesntExistShouldReturnNull()
        {
            // Assign
            var statsCollection = new StatsCollection(new List <IStatsProvider>()
            {
                new FakeStatsProvider()
            });

            // Act
            statsCollection.Prepare();

            // Assert
            Assert.IsNull(statsCollection.Get("NonExistent", "Nope"));
            Assert.IsNull(statsCollection.GetCategory("NonExistent"));
        }
コード例 #3
0
        public void InitializingStatsCollectionShouldUseDataProviderToFill()
        {
            // Assign
            var statsCollection = new StatsCollection(new List <IStatsProvider>()
            {
                new FakeStatsProvider()
            });

            // Act
            statsCollection.Prepare();

            // Assert
            Assert.IsTrue(statsCollection.ContainsCategory("Default"));
            Assert.IsTrue(statsCollection.ContainsStat("Default", "Health"));
            Assert.IsNotNull(statsCollection.Get("Default", "Health"));
            Assert.IsNotNull(statsCollection.GetCategory("Default"));
        }