Beispiel #1
0
        public void killTarget()
        {
            var targetable = new MockTargetable();

            targetable.setup();

            // pre conditions
            Assert.IsFalse(targetable.isDead);
            Assert.AreEqual(0, targetable.deaths);

            // do some damage
            targetable.pool.dealDamage(10);
            Assert.IsFalse(targetable.isDead);
            Assert.AreEqual(90, targetable.pool.health);
            Assert.AreEqual(100, targetable.pool.maxHealth);
            Assert.AreEqual(-10, targetable.deltaHealth);
            Assert.AreEqual(0, targetable.deltaMaxHealth);
            Assert.AreEqual(0, targetable.deaths);

            // kill the target
            targetable.pool.dealDamage(90);
            Assert.IsTrue(targetable.isDead);
            Assert.AreEqual(0, targetable.pool.health);
            Assert.AreEqual(100, targetable.pool.maxHealth);
            Assert.AreEqual(-100, targetable.deltaHealth);
            Assert.AreEqual(0, targetable.deltaMaxHealth);
            Assert.AreEqual(1, targetable.deaths);

            // can't die twice (shouldn't affect health)
            targetable.pool.dealDamage(50);
            Assert.IsTrue(targetable.isDead);
            Assert.AreEqual(0, targetable.pool.health);
            Assert.AreEqual(100, targetable.pool.maxHealth);
            Assert.AreEqual(-100, targetable.deltaHealth);
            Assert.AreEqual(0, targetable.deltaMaxHealth);
            Assert.AreEqual(1, targetable.deaths);

            targetable.tearDown();
        }
Beispiel #2
0
        public void RunEvolutionTargetable_WhenNoUnexecutedEvolutionsExist_ThenEvolutionFilesCreated()
        {
            // Arrange
            var fileRepo      = new Mock <IFileRepo>();
            var evolutionRepo = new Mock <IEvolutionRepo>();

            evolutionRepo.Setup(s => s.GetExecutedEvolutionFileNames()).Returns(new[] { "date_ExFile1", "date_ExFile2" });
            evolutionRepo.Setup(s => s.ExecuteEvolution(It.IsAny <string>())).Verifiable();
            evolutionRepo.Setup(s => s.AddEvolution(It.IsAny <Model.Evolution>(), It.IsAny <string>())).Verifiable();
            fileRepo.Setup(s => s.GetUnexecutedEvolutionFiles(It.IsAny <string[]>())).Returns(new string[] {});
            fileRepo.Setup(s => s.GetEvolutionFileContent(It.IsAny <Model.Evolution>())).Returns(string.Empty);
            var       newEvolution = new MockTargetable();
            const int expected     = 0;

            // Act
            var actual = new EvolutionLogic(evolutionRepo.Object, fileRepo.Object).Run(newEvolution);

            // Assert
            Assert.Equal(expected, actual);
            evolutionRepo.Verify(v => v.ExecuteEvolution(It.IsAny <string>()), Times.Never);
            evolutionRepo.Verify(v => v.AddEvolution(It.IsAny <Model.Evolution>(), It.IsAny <string>()), Times.Never);
        }