コード例 #1
0
 public HomeController(WitcherLogic WitcherLogic, HumanLogic HumanLogic, MonsterLogic MonsterLogic, StatLogic StatLogic)
 {
     this.WitcherLogic = WitcherLogic;
     this.HumanLogic   = HumanLogic;
     this.MonsterLogic = MonsterLogic;
     this.StatLogic    = StatLogic;
 }
コード例 #2
0
        public void GetAllWitchers()
        {
            Mock <IRepository <Witcher> > mock = new Mock <IRepository <Witcher> >(MockBehavior.Loose);
            List <Witcher> TList = new List <Witcher>()
            {
                new Witcher()
                {
                    Name = "Geralt of Testia", Age = 40, AvaragePay = 440, School = "School of the Wolf"
                },
                new Witcher()
                {
                    Name = "Fred", Age = 50, AvaragePay = 350, School = "School of the Cat"
                },
                new Witcher()
                {
                    Name = "Bob", Age = 35, AvaragePay = 4000, School = "School of the Griffin"
                }
            };

            mock.Setup(x => x.GetAll()).Returns(TList.AsQueryable);

            //---
            WitcherLogic wl     = new WitcherLogic(mock.Object);
            var          output = wl.GetAll();

            //---
            List <Witcher> WList = new List <Witcher>()
            {
                TList[0], TList[1], TList[2]
            };

            Assert.That(output, Is.EquivalentTo(WList));
            Assert.That(output.Count, Is.EqualTo(WList.Count));
        }
コード例 #3
0
        public void AddWitcher()
        {
            Mock <IRepository <Witcher> > mock1 = new Mock <IRepository <Witcher> >(MockBehavior.Loose);

            mock1.Setup(x => x.Add(It.IsAny <Witcher>()));
            WitcherLogic wl = new WitcherLogic(mock1.Object);

            Witcher w1 = new Witcher {
                Name = "Gezu", Age = 5, AvaragePay = 555, School = "School of the Viper"
            };

            wl.Add(w1);

            mock1.Verify(x => x.Add(w1), Times.Once);
        }
コード例 #4
0
        public void GetWitcher()
        {
            Mock <IRepository <Witcher> > mock4 = new Mock <IRepository <Witcher> >(MockBehavior.Loose);
            Witcher w2 = new Witcher {
                Name = "John", Age = 99, AvaragePay = 120, School = "School of the Bear"
            };

            string randomid = "random1234";

            mock4.Setup(x => x.Read(randomid)).Returns(w2);
            WitcherLogic wl = new WitcherLogic(mock4.Object);

            //---
            Witcher w3 = wl.Read(randomid);

            Assert.That(w3, Is.EqualTo(w2));
        }
コード例 #5
0
 public EditController(WitcherLogic wlogic, HumanLogic hlogic, MonsterLogic mlogic)
 {
     this.wlogic = wlogic;
     this.hlogic = hlogic;
     this.mlogic = mlogic;
 }
コード例 #6
0
 public WitcherController(WitcherLogic logic)
 {
     this.logic = logic;
 }