Exemplo n.º 1
0
        public void WhenResponseIsInvalid_ReturnsNull()
        {
            var vendorService = new Vendor2ServiceWrapper(null, null, null);
            var response      = JsonConvert.SerializeObject(new { charge = 4.45m });

            // don't want the app to crash if the vendor changes the api contract
            Assert.Null(vendorService.ParseResponse(response));
            // handle unexpected response
            Assert.Null(vendorService.ParseResponse("error"));
        }
Exemplo n.º 2
0
        public void WhenResponseIsNull_ReturnsNull()
        {
            var vendorService = new Vendor2ServiceWrapper(null, null, null);
            var response      = JsonConvert.SerializeObject(new{ amount = (decimal?)null });

            Assert.Null(vendorService.ParseResponse(response));
        }
Exemplo n.º 3
0
        public void WhenResponseContainsTotal_ReturnsValue(decimal val)
        {
            var vendorService = new Vendor2ServiceWrapper(null, null, null);
            var response      = JsonConvert.SerializeObject(new{ amount = val });

            Assert.Equal(val, vendorService.ParseResponse(response));
        }
Exemplo n.º 4
0
        public void WhenResponseContainsOtherProperties_ReturnsTotal()
        {
            var vendorService = new Vendor2ServiceWrapper(null, null, null);
            var response      = JsonConvert.SerializeObject(
                new {
                amount      = 4.45m,
                description = "new property"
            }
                );

            Assert.Equal(4.45m, vendorService.ParseResponse(response));
        }