예제 #1
0
        public void CreateDataModel_InitialisesModelFromConfiguration()
        {
            string requestData = "anyoldShizzle";

            PostDataModel postDataModel = _createVerifonePostProcess.CreateDataModel(requestData);

            Assert.AreEqual(null, postDataModel.api);               // ConfigurationManager.AppSettings["Verifone:PostData:Api"];
            Assert.AreEqual(null, postDataModel.merchantid);        // ConfigurationManager.AppSettings["Verifone:Merchant:MerchantId"]
            Assert.AreEqual(null, postDataModel.systemid);          // ConfigurationManager.AppSettings["Verifone:Merchant:SystemId"]
            Assert.AreEqual("eftrequest", postDataModel.requesttype);
            Assert.AreEqual("anyoldShizzle", postDataModel.requestdata);

            Assert.Inconclusive("Unable to unit test completely. Should be taking IApplicationSettingsReader as a method parameter, so as to be able to mock config.");
        }
예제 #2
0
        public string CreatePayload(PaymentOptionsVm accountVm)
        {
            using (var sr = new StreamReader("Verifone/PostData-template.txt"))
            {
                _postdataTemplateXml = sr.ReadToEnd();
            }

            using (var sr = new StreamReader("Verifone/EftRequest-template.txt"))
            {
                _requestTemplateXml = sr.ReadToEnd();
            }

            var requestDataModel = _createVerifoneRequestProcess.CreateDataModel(accountVm);

            var formattedRequestXml = _requestTemplateXml.FormatWith(requestDataModel);

            var htmlEncodedRequest = HttpUtility.HtmlEncode(formattedRequestXml);

            var postDataModel = _createVerifonePostProcess.CreateDataModel(htmlEncodedRequest);

            var formattedPostDataXml = _postdataTemplateXml.FormatWith(postDataModel);

            return(formattedPostDataXml);
        }