コード例 #1
0
        public void CallByNameTest()
        {
            //expected
            Horse   horse   = new Horse("Шептало", "ч");
            Deer    deer    = new Deer("Олень", "ч");
            Deer    deer1   = new Deer("Олень", "ч");
            Pasture pasture = new Pasture();

            pasture.Add(horse);
            pasture.Add(deer);
            pasture.Add(deer1);
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            string        expexted     = "expexted";
            List <string> expectedList = new List <string>()
            {
                "expectedList"
            };

            Mock.Arrange(() => deer.Voice()).Returns(expexted);
            Mock.Arrange(() => deer1.Voice()).Returns(expexted);
            Mock.Arrange(() => pastureStub.Call(Arg.IsAny <string>())).Returns(expectedList);

            // actual
            List <string> list = pasture.Call("Олень");

            Assert.AreEqual(expexted, list[0]);
            Assert.AreEqual(expexted, list[1]);
            Assert.AreEqual(expectedList[0], list[2]);
            Assert.AreEqual(3, list.Count);
        }
コード例 #2
0
        public void CallTest()
        {
            //expected
            Horse   horse   = new Horse("Шептало", "ч");
            Pasture pasture = new Pasture();

            pasture.Add(horse);
            PastureStub pastureStub = new PastureStub();

            pasture.pasture = pastureStub;
            string        expexted     = "expexted";
            List <string> expectedList = new List <string>()
            {
                "expectedList"
            };

            Mock.Arrange(() => horse.Voice()).Returns(expexted);
            Mock.Arrange(() => pastureStub.Call()).Returns(expectedList);

            // actual
            List <string> list = pasture.Call();

            Assert.AreEqual(expexted, list[0]);
            Assert.AreEqual(expectedList[0], list[1]);
        }