public void Mocking_works_OK_with_Moq_etc() { // arrange var fakeWeaponStore = new Mock<IWeaponStore>(); fakeWeaponStore.Setup(ws => ws.GetIfAvailable(It.IsAny<Weapon>())).Returns(Weapon.Chainsaw); var robot = new ED209(fakeWeaponStore.Object); // act robot.Fire(); // assert fakeWeaponStore.Verify( r => r.GetIfAvailable(It.IsAny<Weapon>())); }
public void Mocking_without_a_famework_is_a_bit_heavyweight() { // arrange var fakeWeaponStore = new MockWeaponStore(); fakeWeaponStore.weaponToReturn = Weapon.Lazer; var robot = new ED209(fakeWeaponStore); // act var result = robot.Fire(); // assert Assert.That(result, Is.EqualTo(Weapon.Lazer)); }