public void TestCreatePlan_Full()
        {
            createPlan create = new createPlan();

            create.planCode               = "abc";
            create.name                   = "thePlan";
            create.description            = "theDescription";
            create.intervalType           = intervalType.ANNUAL;
            create.amount                 = 100;
            create.numberOfPayments       = 3;
            create.trialNumberOfIntervals = 2;
            create.trialIntervalType      = trialIntervalType.MONTH;
            create.active                 = true;

            String actual   = create.Serialize();
            String expected = @"
<createPlan>
<planCode>abc</planCode>
<name>thePlan</name>
<description>theDescription</description>
<intervalType>ANNUAL</intervalType>
<amount>100</amount>
<numberOfPayments>3</numberOfPayments>
<trialNumberOfIntervals>2</trialNumberOfIntervals>
<trialIntervalType>MONTH</trialIntervalType>
<active>true</active>
</createPlan>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #2
0
        public createPlanResponse CreatePlan(createPlan createPlan)
        {
            litleOnlineRequest request = createLitleOnlineRequest();

            request.createPlan = createPlan;

            litleOnlineResponse response           = sendToLitle(request);
            createPlanResponse  createPlanResponse = response.createPlanResponse;

            return(createPlanResponse);
        }
Exemple #3
0
        public void TestCreatePlan()
        {
            var createPlan = new createPlan();

            batchRequest.addCreatePlan(createPlan);

            Assert.AreEqual(1, batchRequest.getNumCreatePlans());

            mockCnpFile.Verify(cnpFile => cnpFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), mockCnpTime.Object));
            mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, createPlan.Serialize()));
        }
Exemple #4
0
        public void testCreatePlan()
        {
            createPlan createPlan = new createPlan();

            batchRequest.addCreatePlan(createPlan);

            Assert.AreEqual(1, batchRequest.getNumCreatePlans());

            mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, createPlan.Serialize()));
        }
Exemple #5
0
 public void addCreatePlan(createPlan createPlan)
 {
     if (numAccountUpdates == 0)
     {
         numCreatePlans++;
         tempBatchFilePath = saveElement(litleFile, litleTime, tempBatchFilePath, createPlan);
     }
     else
     {
         throw new LitleOnlineException(accountUpdateErrorMessage);
     }
 }
Exemple #6
0
        public void TestCreatePlan()
        {
            createPlan createPlan = new createPlan();

            createPlan.planCode = "theCode";

            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<cnpOnlineRequest.*?<createPlan.*?<planCode>theCode</planCode>.*?</createPlan>.*?", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >()))
            .Returns("<cnpOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><createPlanResponse><planCode>theCode</planCode></createPlanResponse></cnpOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            cnp.SetCommunication(mockedCommunication);
            createPlanResponse createPlanResponse = cnp.CreatePlan(createPlan);

            Assert.AreEqual("theCode", createPlanResponse.planCode);
        }
        public void TestCreatePlan_OnlyRequired()
        {
            createPlan create = new createPlan();

            create.planCode     = "abc";
            create.name         = "thePlan";
            create.intervalType = intervalType.ANNUAL;
            create.amount       = 100;

            String actual   = create.Serialize();
            String expected = @"
<createPlan>
<planCode>abc</planCode>
<name>thePlan</name>
<intervalType>ANNUAL</intervalType>
<amount>100</amount>
</createPlan>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #8
0
        public void TestCreatePlan_OnlyRequired()
        {
            var create = new createPlan();

            create.planCode     = "abc";
            create.name         = "thePlan";
            create.intervalType = intervalType.ANNUAL;
            create.amount       = 100;

            var actual   = create.Serialize();
            var expected = @"
<createPlan>
<planCode>abc</planCode>
<name>thePlan</name>
<intervalType>ANNUAL</intervalType>
<amount>100</amount>
</createPlan>";

            Assert.AreEqual(expected, actual);
        }
        public void testCreatePlan()
        {
            var createPlan = new createPlan();

            createPlan.planCode = "theCode";

            var mock = new Mock <Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                Communications.HttpPost(
                    It.IsRegex(
                        ".*?<litleOnlineRequest.*?<createPlan.*?<planCode>theCode</planCode>.*?</createPlan>.*?",
                        RegexOptions.Singleline), It.IsAny <Dictionary <string, string> >()))
            .Returns(
                "<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><createPlanResponse><planCode>theCode</planCode></createPlanResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            var createPlanResponse = litle.CreatePlan(createPlan);

            Assert.AreEqual("theCode", createPlanResponse.planCode);
        }
 public createPlanResponse CreatePlan(createPlan transaction)
 {
     return(this.SendTransaction <createPlanResponse>(transaction));
 }
Exemple #11
0
 public createPlanResponse CreatePlan(createPlan createPlan)
 {
     return(SendRequest(response => response.createPlanResponse, createPlan));
 }
        public void TestCreatePlan_OnlyRequired()
        {
            var create = new createPlan();
            create.planCode = "abc";
            create.name = "thePlan";
            create.intervalType = intervalType.ANNUAL;
            create.amount = 100;

            var actual = create.Serialize();
            var expected = @"
            <createPlan>
            <planCode>abc</planCode>
            <name>thePlan</name>
            <intervalType>ANNUAL</intervalType>
            <amount>100</amount>
            </createPlan>";
            Assert.AreEqual(expected, actual);
        }
        public void TestCreatePlan_Full()
        {
            var create = new createPlan();
            create.planCode = "abc";
            create.name = "thePlan";
            create.description = "theDescription";
            create.intervalType = intervalType.ANNUAL;
            create.amount = 100;
            create.numberOfPayments = 3;
            create.trialNumberOfIntervals = 2;
            create.trialIntervalType = trialIntervalType.MONTH;
            create.active = true;

            var actual = create.Serialize();
            var expected = @"
            <createPlan>
            <planCode>abc</planCode>
            <name>thePlan</name>
            <description>theDescription</description>
            <intervalType>ANNUAL</intervalType>
            <amount>100</amount>
            <numberOfPayments>3</numberOfPayments>
            <trialNumberOfIntervals>2</trialNumberOfIntervals>
            <trialIntervalType>MONTH</trialIntervalType>
            <active>true</active>
            </createPlan>";
            Assert.AreEqual(expected, actual);
        }
        public void testCreatePlan()
        {
            var createPlan = new createPlan();
            createPlan.planCode = "theCode";

            var mock = new Mock<Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                    Communications.HttpPost(
                        It.IsRegex(
                            ".*?<litleOnlineRequest.*?<createPlan.*?<planCode>theCode</planCode>.*?</createPlan>.*?",
                            RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns(
                    "<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><createPlanResponse><planCode>theCode</planCode></createPlanResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            var createPlanResponse = litle.CreatePlan(createPlan);
            Assert.AreEqual("theCode", createPlanResponse.planCode);
        }
        public void testCreatePlan()
        {
            var createPlan = new createPlan();
            createPlan.planCode = "thePlanCode";
            createPlan.name = "theName";
            createPlan.intervalType = intervalType.ANNUAL;
            createPlan.amount = 100;

            var mockLitleResponse = new Mock<litleResponse>();
            var mockLitleXmlSerializer = new Mock<litleXmlSerializer>();

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml())
                .Returns(
                    "<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></createPlanResponse>")
                .Returns(
                    "<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></createPlanResponse>");

            var mockLitleBatchResponse = new batchResponse();
            mockLitleBatchResponse.setCreatePlanResponseReader(mockXmlReader.Object);

            mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse);
            var mockedLitleResponse = mockLitleResponse.Object;

            mockLitleXmlSerializer.Setup(
                litleXmlSerializer =>
                    litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>()))
                .Returns(mockedLitleResponse);

            var mockedCommunication = mockCommunications.Object;
            litle.setCommunication(mockedCommunication);

            var mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;
            litle.setLitleXmlSerializer(mockedLitleXmlSerializer);

            var mockedLitleFile = mockLitleFile.Object;
            litle.setLitleFile(mockedLitleFile);

            litle.setLitleTime(mockLitleTime.Object);

            var litleBatchRequest = new batchRequest(_mockCache.Object);
            litleBatchRequest.setLitleFile(mockedLitleFile);
            litleBatchRequest.setLitleTime(mockLitleTime.Object);
            litleBatchRequest.addCreatePlan(createPlan);
            litleBatchRequest.addCreatePlan(createPlan);
            litle.addBatch(litleBatchRequest);

            var batchFileName = litle.sendToLitle();
            var actualLitleResponse = litle.receiveFromLitle(batchFileName);
            var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse();

            Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse);
            Assert.AreEqual("123", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId);
            Assert.AreEqual("124", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId);
            Assert.IsNull(actualLitleBatchResponse.nextCreatePlanResponse());

            mockCommunications.Verify(
                Communications =>
                    Communications.FtpDropOff(It.IsAny<string>(), mockFileName, It.IsAny<Dictionary<string, string>>()));
            mockCommunications.Verify(
                Communications =>
                    Communications.FtpPickUp(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), mockFileName));
        }
        public void testCreatePlan()
        {
            var createPlan = new createPlan();

            batchRequest.addCreatePlan(createPlan);

            Assert.AreEqual(1, batchRequest.getNumCreatePlans());

            mockLitleFile.Verify(
                litleFile =>
                    litleFile.createRandomFile(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
                        mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, createPlan.Serialize()));
        }