예제 #1
0
        public IActionResult Repair(string code)
        {
            var service = new TieFighterRepairService(_tieFighterRepository);

            service.RepairTieFighterByCode(code);

            return(Ok());
        }
        public void TestRepairTieFighter()
        {
            var repo = new Mock <ITieFighterRepository>();

            repo.Setup(m => m.GetTieFighterByCode(It.IsAny <string>())).Returns((string code) =>
            {
                return(_data.SingleOrDefault(d => d.Code == code));
            });

            Assert.DoesNotThrow(() =>
            {
                var repairer = new TieFighterRepairService(repo.Object);
                repairer.RepairTieFighterByCode("ABC");
                repairer.RepairTieFighterByCode("XYZ");
            });

            Assert.IsFalse(_data.SingleOrDefault(d => d.Code == "ABC").IsDamaged);
        }