public void 小红100斤_吃了20斤西瓜_体重120斤名字叫不减肥就不改名的张小红() { //Arrange var xiaohong = new Mock <IMan>(); xiaohong.SetupProperty(fake => fake.Name, "张小红"); xiaohong.SetupProperty(fake => fake.Weight, 100); xiaohong.Setup(fake => fake.Eat(20)) .Callback <int>(num => { xiaohong.Object.Weight += num; xiaohong.Raise(fake1 => fake1.ImFull += null, new EventArgs()); }); //Act FamilyGathering.HaveDinner(xiaohong.Object, "西瓜", 20); //Assert Assert.AreEqual(120, xiaohong.Object.Weight); Assert.AreEqual("不减肥就不改名的张小红", xiaohong.Object.Name); }
public void 小红100斤_吃西瓜_体重增加名字变化(int foodNum, int weight, string name) { //Arrange var xiaohong = new Mock <IMan>(); xiaohong.SetupProperty(fake => fake.Name, "张小红"); xiaohong.SetupProperty(fake => fake.Weight, 100); xiaohong.Setup(fake => fake.Eat(It.IsInRange(0, 15, Range.Exclusive))) .Callback <int>(num => { xiaohong.Object.Weight += num; }); xiaohong.Setup(fake => fake.Eat(It.IsInRange(15, int.MaxValue, Range.Inclusive))) .Callback <int>(num => { xiaohong.Object.Weight += num; xiaohong.Raise(fake1 => fake1.ImFull += null, new EventArgs()); }); //Act FamilyGathering.HaveDinner(xiaohong.Object, "西瓜", foodNum); //Assert Assert.AreEqual(weight, xiaohong.Object.Weight); Assert.AreEqual(name, xiaohong.Object.Name); }