Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }