Commit 64b8275b authored by datdiep's avatar datdiep

fix

parent 15a3e888
Pipeline #15868 canceled with stages
...@@ -5,21 +5,17 @@ using System.Linq; ...@@ -5,21 +5,17 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UF.AssessmentProject.Controllers; using UF.AssessmentProject.Controllers;
using UF.AssessmentProject.Helper;
using Xunit; using Xunit;
namespace TestProject1 namespace TestProject1
{ {
public class ControllerTest public class ControllerTest
{ {
private readonly TransactionController _controller; TransactionController _controller = new TransactionController();
public ControllerTest(TransactionController controller)
{
_controller = controller;
}
[Fact] [Fact]
public void add_transaction() public void Expired()
{ {
var rq = new UF.AssessmentProject.Model.Transaction.RequestMessage() var rq = new UF.AssessmentProject.Model.Transaction.RequestMessage()
{ {
...@@ -47,9 +43,49 @@ namespace TestProject1 ...@@ -47,9 +43,49 @@ namespace TestProject1
} }
} }
}; };
var createdResponse = _controller.SubmitTRansaction(rq); ActionResult<UF.AssessmentProject.Model.Transaction.ResponseMessage> rs = _controller.SubmitTRansaction(rq);
Assert.IsType<CreatedAtActionResult>(createdResponse); var actual = (OkObjectResult)rs.Result;
var resultmessage = actual.Value as UF.AssessmentProject.Model.Transaction.ResponseMessage;
Assert.Equal("Expired!", resultmessage.resultmessage);
}
[Fact]
public void Access_denied()
{
var rq = new UF.AssessmentProject.Model.Transaction.RequestMessage()
{
partnerkey = "aaa",
partnerpassword = "FG-00001",
partnerrefno = "RkFLRVBBU1NXT1JEMTIzNA==",
totalamount = 1000,
items = new List<UF.AssessmentProject.Model.Transaction.itemdetail>()
{
new UF.AssessmentProject.Model.Transaction.itemdetail()
{
name = "i-00001",
partneritemref = "Pen",
qty = 5,
unitprice = 2
},
new UF.AssessmentProject.Model.Transaction.itemdetail()
{
name = "i-00002",
partneritemref = "Ruler",
qty = 1,
unitprice = 100
}
}
};
rq.timestamp = DateTime.Now.ToString();
var rawsign = DateTime.Parse(rq.timestamp).ToString("yyyyMMddHHmmss") + rq.partnerkey + rq.partnerrefno + rq.totalamount + rq.partnerpassword;
string sig = CommonUtils.ComputeSha256Hash((CommonUtils.EncodeBase64(rawsign)));
rq.sig = sig;
ActionResult<UF.AssessmentProject.Model.Transaction.ResponseMessage> rs = _controller.SubmitTRansaction(rq);
var actual = (OkObjectResult)rs.Result;
var resultmessage = actual.Value as UF.AssessmentProject.Model.Transaction.ResponseMessage;
Assert.Equal("Access Denied!", resultmessage.resultmessage);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment