using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UF.AssessmentProject.Controllers;
using Xunit;

namespace TestProject1
{
    public class ControllerTest
    {
        private readonly TransactionController _controller;

        public ControllerTest(TransactionController controller)
        {
            _controller = controller;
        }

        [Fact]
        public void add_transaction()
        {
            var rq = new UF.AssessmentProject.Model.Transaction.RequestMessage()
            {
                partnerkey = "FAKEGOOGLE",
                partnerpassword = "FG-00001",
                partnerrefno = "RkFLRVBBU1NXT1JEMTIzNA==",
                sig = "24XYSmvKGH9I9Y5FLvSsId2MPtjkvog7U5JLhE3m30A=",
                timestamp = "2013-11-22T02:11:22.0000000Z",
                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
                    }
                }
            };
            var createdResponse = _controller.SubmitTRansaction(rq);
            Assert.IsType<CreatedAtActionResult>(createdResponse);

        }
    }
}