public async Task TestLinkSetsPaymentDictionary() { // Arrange Dictionary <string, string> dictionary = null; MockDataSigningService.Setup(a => a.Sign(It.IsAny <Dictionary <string, string> >())).Returns("FakeSign").Callback <Dictionary <string, string> >(c => dictionary = c); OrderData[1].Status = OrderStatusCodes.Finalized; OrderData[1].PaymentType = PaymentTypeCodes.CreditCard; OrderData[1].Paid = false; var od = OrderData[1].GetOrderDetails(); od.AdjustmentAmount = 2.51m; OrderData[1].SaveDetails(od); // Act var controllerResult = await Controller.Link(OrderData[1].ShareIdentifier); // Assert var result = Assert.IsType <ViewResult>(controllerResult); var modelResult = Assert.IsType <OrderResultsModel>(result.Model); modelResult.PaymentDictionary.Count.ShouldBe(16); foreach (var dictItem in dictionary) { modelResult.PaymentDictionary[dictItem.Key].ShouldBe(dictItem.Value); } }
public async Task TestLinkSetsViewbagSignature() { // Arrange Dictionary <string, string> dictionary = null; MockDataSigningService.Setup(a => a.Sign(It.IsAny <Dictionary <string, string> >())).Returns("FakeSign").Callback <Dictionary <string, string> >(c => dictionary = c); OrderData[1].Status = OrderStatusCodes.Finalized; OrderData[1].PaymentType = PaymentTypeCodes.CreditCard; OrderData[1].Paid = false; // Act var controllerResult = await Controller.Link(OrderData[1].ShareIdentifier); // Assert Assert.IsType <ViewResult>(controllerResult); ((string)Controller.ViewBag.Signature).ShouldBe("FakeSign"); }
public async Task TestLinkCallsSetDictWhenUnpaidCreditCard() { // Arrange Dictionary <string, string> dictionary = null; MockDataSigningService.Setup(a => a.Sign(It.IsAny <Dictionary <string, string> >())).Returns("FakeSign").Callback <Dictionary <string, string> >(c => dictionary = c); OrderData[1].Status = OrderStatusCodes.Finalized; OrderData[1].PaymentType = PaymentTypeCodes.CreditCard; OrderData[1].Paid = false; // Act var controllerResult = await Controller.Link(OrderData[1].ShareIdentifier); // Assert Assert.IsType <ViewResult>(controllerResult); MockDataSigningService.Verify(a => a.Sign(It.IsAny <Dictionary <string, string> >()), Times.Once); dictionary.ShouldNotBeNull(); }
public async Task TestLinkSetsCyberSourceUrl() { // Arrange Dictionary <string, string> dictionary = null; MockDataSigningService.Setup(a => a.Sign(It.IsAny <Dictionary <string, string> >())).Returns("FakeSign").Callback <Dictionary <string, string> >(c => dictionary = c); OrderData[1].Status = OrderStatusCodes.Finalized; OrderData[1].PaymentType = PaymentTypeCodes.CreditCard; OrderData[1].Paid = false; // Act var controllerResult = await Controller.Link(OrderData[1].ShareIdentifier); // Assert var result = Assert.IsType <ViewResult>(controllerResult); var modelResult = Assert.IsType <OrderResultsModel>(result.Model); modelResult.CyberSourceUrl.ShouldBe("Http://FakeUrl.com"); }
public async Task TestLinkCallsSetsDictToExpectedValuesWhenUnpaidCreditCard() { // Arrange Dictionary <string, string> dictionary = null; MockDataSigningService.Setup(a => a.Sign(It.IsAny <Dictionary <string, string> >())).Returns("FakeSign").Callback <Dictionary <string, string> >(c => dictionary = c); OrderData[1].Status = OrderStatusCodes.Finalized; OrderData[1].PaymentType = PaymentTypeCodes.CreditCard; OrderData[1].Paid = false; var od = OrderData[1].GetOrderDetails(); od.AdjustmentAmount = 2.51m; OrderData[1].SaveDetails(od); // Act var controllerResult = await Controller.Link(OrderData[1].ShareIdentifier); // Assert Assert.IsType <ViewResult>(controllerResult); MockDataSigningService.Verify(a => a.Sign(It.IsAny <Dictionary <string, string> >()), Times.Once); dictionary.ShouldNotBeNull(); dictionary.Count.ShouldBe(16); dictionary["transaction_type"].ShouldBe("sale"); dictionary["reference_number"].ShouldBe("2"); dictionary["amount"].ShouldBe("2.51"); dictionary["currency"].ShouldBe("USD"); dictionary["access_key"].ShouldBe("123"); dictionary["profile_id"].ShouldBe("myProfile"); dictionary["transaction_uuid"].ShouldNotBeNull(); dictionary["signed_date_time"].ShouldNotBeNull(); dictionary["unsigned_field_names"].ShouldBe(string.Empty); dictionary["locale"].ShouldBe("en"); dictionary["bill_to_email"].ShouldBe("*****@*****.**"); dictionary["bill_to_forename"].ShouldBe("FirstName2"); dictionary["bill_to_surname"].ShouldBe("LastName2"); dictionary["bill_to_address_country"].ShouldBe("US"); dictionary["bill_to_address_state"].ShouldBe("CA"); dictionary["signed_field_names"].ShouldBe("signed_field_names,transaction_type,reference_number,amount,currency,access_key,profile_id,transaction_uuid,signed_date_time,unsigned_field_names,locale,bill_to_email,bill_to_forename,bill_to_surname,bill_to_address_country,bill_to_address_state"); }