public void Test_Send_Reg_Code_Fake() { // arrange FakeSmsSender smsSender = new FakeSmsSender(); UserRegService userRegService = new UserRegService(smsSender); // act var result = userRegService.SendRegCode("13912345678"); // asset Assert.AreEqual(result, SendRegCodeResult.Ok); }
public void Test_send_reg_code_wrong_format() { // arrange Mock <ISmsSender> moqSmsSender = new Mock <ISmsSender>(); var userRegService = new UserRegService(moqSmsSender.Object); // act var result = userRegService.SendRegCode("1390000"); // asset Assert.AreEqual(result, SendRegCodeResult.WrongFormat); moqSmsSender.Verify(x => x.Send(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public void Test_send_reg_code_ok() { // arrange Mock <ISmsSender> moqSmsSender = new Mock <ISmsSender>(); var userRegService = new UserRegService(moqSmsSender.Object); var mobile = "13800000000"; // act var result = userRegService.SendRegCode(mobile); // asset Assert.AreEqual(result, SendRegCodeResult.Ok); moqSmsSender.Verify(x => x.Send(mobile, It.IsAny <string>()), Times.Exactly(1)); }