Beispiel #1
0
        public void Constructor_ShouldInstantiateFieldsCorrectly()
        {
            var mockedCreaturesFactory = new Mock <ICreaturesFactory>();
            var mockedLogger           = new Mock <ILogger>();

            var battleManager = new BattleManagerWithThreeArmies(mockedCreaturesFactory.Object, mockedLogger.Object);
            var privateObject = new PrivateObject(battleManager);

            var resultThirdArmy = privateObject.GetField("thirdArmyCreatures") as ICollection <ICreaturesInBattle>;

            Assert.AreEqual(new List <ICreaturesInBattle>(), resultThirdArmy);
        }
Beispiel #2
0
        public void Constructor_ShouldCallBaseConstructorAndinstantiateAllProperties()
        {
            var creaturesFactoryMock = new Mock <ICreaturesFactory>();
            var loggerMock           = new Mock <ILogger>();

            var battleManager = new BattleManagerWithThreeArmies(creaturesFactoryMock.Object, loggerMock.Object);

            var firstArmy = battleManager
                            .GetType()
                            .BaseType
                            .GetField("firstArmyCreatures", BindingFlags.NonPublic | BindingFlags.Instance)
                            .GetValue(battleManager);

            var secondArmy = battleManager
                             .GetType()
                             .BaseType
                             .GetField("secondArmyCreatures", BindingFlags.NonPublic | BindingFlags.Instance)
                             .GetValue(battleManager);

            var creaturesFactory = battleManager
                                   .GetType()
                                   .BaseType
                                   .GetField("creaturesFactory", BindingFlags.NonPublic | BindingFlags.Instance)
                                   .GetValue(battleManager);

            var logger = battleManager
                         .GetType()
                         .BaseType
                         .GetField("logger", BindingFlags.NonPublic | BindingFlags.Instance)
                         .GetValue(battleManager);

            Assert.That(firstArmy, Is.Not.Null.And.InstanceOf <ICollection <ICreaturesInBattle> >());
            Assert.That(secondArmy, Is.Not.Null.And.InstanceOf <ICollection <ICreaturesInBattle> >());
            Assert.That(creaturesFactory, Is.Not.Null.And.InstanceOf <ICreaturesFactory>());
            Assert.That(logger, Is.Not.Null.And.InstanceOf <ILogger>());
        }