예제 #1
0
        public void HandlesId()
        {
            var value = "ch_123";

            string id     = null;
            Charge charge = null;

            StringOrObject <Charge> .Map(value, s => id = s, o => charge = o);

            Assert.Equal("ch_123", id);
            Assert.Null(charge);
        }
예제 #2
0
        public void HandlesUnknownObjectWithoutId()
        {
            var json  = "{\"object\": \"bar\"}";
            var value = JObject.Parse(json);

            string           id      = null;
            IExternalAccount account = null;

            StringOrObject <IExternalAccount> .Map(value, s => id = s, o => account = o);

            Assert.Null(id);
            Assert.Null(account);
        }
예제 #3
0
        public void HandlesUnknownObjectWithId()
        {
            var json  = "{\"id\": \"foo_123\", \"object\": \"foo\"}";
            var value = JObject.Parse(json);

            string           id      = null;
            IExternalAccount account = null;

            StringOrObject <IExternalAccount> .Map(value, s => id = s, o => account = o);

            Assert.Equal("foo_123", id);
            Assert.Null(account);
        }
예제 #4
0
        public void HandlesObject()
        {
            var json  = "{\"id\": \"ch_123\", \"object\": \"charge\"}";
            var value = JObject.Parse(json);

            string id     = null;
            Charge charge = null;

            StringOrObject <Charge> .Map(value, s => id = s, o => charge = o);

            Assert.Equal("ch_123", id);
            Assert.Equal("ch_123", charge.Id);
            Assert.Equal("charge", charge.Object);
        }