Beispiel #1
0
        public void TestInitFull()
        {
            EcommerceTransaction et = new EcommerceTransaction()
                                      .SetOrderId("orderId")
                                      .SetTotalValue(10.22)
                                      .SetAffiliation("affiliation")
                                      .SetTaxValue(2.5)
                                      .SetShipping(6.3)
                                      .SetCity("London")
                                      .SetState("Shoreditch")
                                      .SetCountry("United Kingdom")
                                      .SetCurrency("GBP")
                                      .SetItems(GetItem())
                                      .Build();

            Assert.NotNull(et);

            Dictionary <string, object> payload = et.GetPayload().GetDictionary();

            Assert.AreEqual(12, payload.Count);
            Assert.AreEqual("tr", payload [Constants.EVENT]);
            Assert.AreEqual("orderId", payload [Constants.TR_ID]);
            Assert.AreEqual("10.22", payload [Constants.TR_TOTAL]);
            Assert.AreEqual("affiliation", payload [Constants.TR_AFFILIATION]);
            Assert.AreEqual("2.50", payload [Constants.TR_TAX]);
            Assert.AreEqual("6.30", payload [Constants.TR_SHIPPING]);
            Assert.AreEqual("London", payload [Constants.TR_CITY]);
            Assert.AreEqual("Shoreditch", payload [Constants.TR_STATE]);
            Assert.AreEqual("United Kingdom", payload [Constants.TR_COUNTRY]);
            Assert.AreEqual("GBP", payload [Constants.TR_CURRENCY]);
        }
Beispiel #2
0
        public void TestInitMinimal()
        {
            EcommerceTransaction et = new EcommerceTransaction().SetOrderId("orderId").SetItems(GetItem()).SetTotalValue(10.20).Build();

            Assert.NotNull(et);

            Dictionary <string, object> payload = et.GetPayload().GetDictionary();

            Assert.AreEqual(5, payload.Count);
            Assert.AreEqual("tr", payload [Constants.EVENT]);
            Assert.AreEqual("orderId", payload [Constants.TR_ID]);
            Assert.AreEqual("10.20", payload [Constants.TR_TOTAL]);
        }
        public void testInitEcommerceTransaction()
        {
            var et = new EcommerceTransaction()
                     .SetOrderId("orderId")
                     .SetTotalValue(20.1)
                     .SetAffiliation("affiliation")
                     .SetTaxValue(1.56)
                     .SetShipping(10.5)
                     .SetCity("city")
                     .SetState("state")
                     .SetCountry("country")
                     .SetCurrency("AUD")
                     .SetItems(new List <EcommerceTransactionItem>())
                     .SetTrueTimestamp(123456789123)
                     .Build();

            Assert.IsNotNull(et);
            Assert.AreEqual(Constants.EVENT_ECOMM, et.GetPayload().Payload[Constants.EVENT]);
            Assert.AreEqual("orderId", et.GetPayload().Payload[Constants.TR_ID]);
            Assert.AreEqual("20.10", et.GetPayload().Payload[Constants.TR_TOTAL]);
            Assert.AreEqual("affiliation", et.GetPayload().Payload[Constants.TR_AFFILIATION]);
            Assert.AreEqual("1.56", et.GetPayload().Payload[Constants.TR_TAX]);
            Assert.AreEqual("10.50", et.GetPayload().Payload[Constants.TR_SHIPPING]);
            Assert.AreEqual("city", et.GetPayload().Payload[Constants.TR_CITY]);
            Assert.AreEqual("state", et.GetPayload().Payload[Constants.TR_STATE]);
            Assert.AreEqual("country", et.GetPayload().Payload[Constants.TR_COUNTRY]);
            Assert.AreEqual("AUD", et.GetPayload().Payload[Constants.TR_CURRENCY]);

            Assert.IsNotNull(et.GetContexts());
            Assert.IsTrue(et.GetPayload().Payload.ContainsKey(Constants.EID));
            Assert.IsTrue(et.GetPayload().Payload.ContainsKey(Constants.TIMESTAMP));
            Assert.IsTrue(et.GetPayload().Payload.ContainsKey(Constants.TRUE_TIMESTAMP));
        }