public void Generate2Test() { TokenEntity tokenEntity = new TokenEntity(); tokenEntity.SetCard(1111222233334444, DateTime.Now, 123); GenerateToken generateToken = new GenerateToken(); var token = generateToken.Generate(tokenEntity); var verify = generateToken.Validate(token, tokenEntity); Assert.True(verify); }
public ActionResult Post([FromBody] TokenModel token) { try { TokenEntity tokenEntity = new TokenEntity(); tokenEntity.SetCard(token.CardNumber, token.Date, token.CVV); return(Response(true, _service.Post(tokenEntity))); } catch (Exception ex) { return(Response(false, ex.Message)); } }
public void GenerateTest() { TokenEntity tokenEntity = new TokenEntity(); tokenEntity.SetCard(1111222233334444, DateTime.Now, 123); var mockIToken = new Mock <IToken>(); mockIToken.Setup(x => x.Generate(tokenEntity)).Returns("1111222233334444"); string token = mockIToken.Object.Generate(tokenEntity); Assert.Equal("1111222233334444", token); }