Esempio n. 1
0
        public void The_metadata_is_retrieved()
        {
            Assert.That(last_http_response.StatusCode, Is.EqualTo(HttpStatusCode.OK));

            var content = last_http_response.Content.ReadAsStringAsync().Result;

            var metaData = new BsonConverter().Deserialise <Metadata>(content);

            Assert.That(metaData.Questions.Count, Is.EqualTo(2));

            var categoryQuestion = metaData.Questions[0];
            var categoryOptions  = categoryQuestion.UnmappedProperties["options"];

            Assert.That(categoryQuestion.Title, Is.EqualTo("Category"));
            Assert.That(categoryQuestion.Id, Is.EqualTo("category"));
            Assert.That(categoryOptions, Is.EquivalentTo(new List <string> {
                "Watches", "Rings"
            }));

            var subcategoryQuestion = metaData.Questions[1];
            var subcategoryOptions  = subcategoryQuestion.UnmappedProperties["options"];

            Assert.That(subcategoryQuestion.Id, Is.EqualTo("subCategory"));
            Assert.That(subcategoryQuestion.Title, Is.EqualTo("Sub category"));
            Assert.That(subcategoryOptions, Is.EquivalentTo(new List <string> {
                "Bracelets", "Toe rings"
            }));
        }
Esempio n. 2
0
        public void The_product_is_retrieved()
        {
            Assert.That(last_http_response.StatusCode, Is.EqualTo(HttpStatusCode.OK));

            var content = last_http_response.Content.ReadAsStringAsync().Result;

            var product = new BsonConverter().Deserialise <Product>(content);

            Assert.That(product.Id, Is.EqualTo(GetOrCreateRandomId(false)));
            Assert.That(product.UnmappedProperties["description"], Is.EqualTo("a test"));
            Assert.That(product.UnmappedProperties["title"], Is.EqualTo("title"));
        }
Esempio n. 3
0
 public byte[] ToByteArray()
 {
     return(BsonConverter.ToByteArray <JObject>(this));
 }
Esempio n. 4
0
 protected GameMessage(byte[] bytes) : this(BsonConverter.FromByteArray <JObject>(bytes))
 {
 }
Esempio n. 5
0
 public static JsonRpc Parse(byte[] bytes)
 {
     return(new JsonRpc(BsonConverter.FromByteArray <JObject>(bytes)));
 }
Esempio n. 6
0
 // byte array -> jobject
 public static JObject ToJObject(this byte[] bytes)
 {
     return(BsonConverter.FromByteArray <JObject>(bytes));
 }
Esempio n. 7
0
 // jobject -> byte array
 public static byte[] ToByteArray(this JObject o)
 {
     return(BsonConverter.ToByteArray(o));
 }