public void CallByNameTest() { //expected Wolf wolf = new Wolf("Вова", "ч"); Wolf wolf1 = new Wolf("Чуйка", "ж"); Wolf wolf2 = new Wolf("Чуйка", "ж"); Volary volary = new Volary(); volary.Add(wolf); volary.Add(wolf1); volary.Add(wolf2); VolaryStub volaryStub = new VolaryStub(); volary.volary = volaryStub; string expexted = "expexted"; List <string> expectedList = new List <string>() { "expectedList" }; Mock.Arrange(() => wolf1.Voice()).Returns(expexted); Mock.Arrange(() => wolf2.Voice()).Returns(expexted); Mock.Arrange(() => volaryStub.Call(Arg.IsAny <string>())).Returns(expectedList); // actual List <string> list = volary.Call("Чуйка"); Assert.AreEqual(expexted, list[0]); Assert.AreEqual(expexted, list[1]); Assert.AreEqual(expectedList[0], list[2]); Assert.AreEqual(3, list.Count); }
public void CallTest() { //expected Wolf wolf = new Wolf("Happy Wolf", "ч"); Volary volary = new Volary(); volary.Add(wolf); VolaryStub volaryStub = new VolaryStub(); volary.volary = volaryStub; string expexted = "expexted"; List <string> expectedList = new List <string>() { "expectedList" }; Mock.Arrange(() => wolf.Voice()).Returns(expexted); Mock.Arrange(() => volaryStub.Call()).Returns(expectedList); // actual List <string> list = volary.Call(); Assert.AreEqual(expexted, list[0]); Assert.AreEqual(expectedList[0], list[1]); }
public void CallByNameTest() { //expected Dog dog = new Dog("Вовкодав", "ч"); Dog dog1 = new Dog("Диктатор", "ч"); Dog dog2 = new Dog("Диктатор", "ч"); Room room = new Room(); room.Add(dog); room.Add(dog1); room.Add(dog2); RoomStub roomStub = new RoomStub(); room.room = roomStub; string expexted = "expexted"; List <string> expectedList = new List <string>() { "expectedList" }; Mock.Arrange(() => dog1.Voice()).Returns(expexted); Mock.Arrange(() => dog2.Voice()).Returns(expexted); Mock.Arrange(() => roomStub.Call(Arg.IsAny <string>())).Returns(expectedList); // actual List <string> list = room.Call("Диктатор"); Assert.AreEqual(expexted, list[0]); Assert.AreEqual(expexted, list[1]); Assert.AreEqual(expectedList[0], list[2]); Assert.AreEqual(3, list.Count); // Кімната для тестування виклику з вольєра. Room room1 = new Room(); Volary volary = new Volary(); room1.volary = volary; List <string> expectedVolary = new List <string>() { "expectedVolary" }; Mock.Arrange(() => volary.Call(Arg.IsAny <string>())).Returns(expectedVolary); List <string> actualList = room1.Call("AnyName"); Assert.AreEqual(expectedVolary[0], actualList[0]); }