public void TestCreateRushObjectAsDynamic() { dynamic obj = new RushObject("User"); obj.Name = "John Doe"; Assert.IsNotNull(obj.Name); }
public void TestCreateRushObjectUsingIndexer() { var obj = new RushObject("User"); obj["Name"] = "John Doe"; Assert.IsNotNull(obj["Name"]); }
public async Task TestSaveRushObjectAsync() { RushObject obj = new RushObject("GameScore"); obj["PlayerName"] = "John Doe"; obj["Score"] = 12000; obj["Array"] = new string[] { "A", "B", "C" }; await obj.SaveAsync(); Assert.IsNotNull(obj.ObjectId); }
public void TestGetFromStoreMongoDbRepository() { var obj = new RushObject("Player"); obj["Name"] = "John Doe"; var store = new StoreMongoDbRepository(); store.Resource = obj.ClassName; store.Insert(obj); var fromDb = store.Get(obj.ObjectId); Assert.IsNotNull(fromDb); }
public static async Task SaveAsync(this RushObject obj, CancellationToken cancellationToken) { var json = JsonConvert.SerializeObject(obj.AsDictionary()); var content = new StringContent(json); var client = new HttpClient(); var result = await client.PostAsync(storeBaseUrl + obj.ClassName, content, cancellationToken); if (result.StatusCode == HttpStatusCode.OK) { var saved = await result.Content.ReadAsStringAsync(); } else { } }
public void TestUpdateStoreMongoDbRepository() { var obj = new RushObject("Player"); obj["Name"] = "John Doe"; var store = new StoreMongoDbRepository(); store.Resource = obj.ClassName; store.Insert(obj); obj["UpdateWorks"] = true; store.Update(obj.ObjectId, obj); Assert.IsNotNull(obj["UpdateWorks"]); }
public void TestInsertIntoStoreMongoDbRepository() { var obj = new RushObject("Player"); obj["Name"] = "John Doe"; obj["Score"] = 1000; obj["Array"] = new string[] { "A", "B", "C" }; var store = new StoreMongoDbRepository(); store.Resource = obj.ClassName; store.Insert(obj); Assert.IsNotNull(obj.ObjectId); Assert.IsNotNull(obj.CreatedAt); }
public void TestDeleteStoreMongoDbRepository() { var obj = new RushObject("Player"); obj["Name"] = "John Doe"; var store = new StoreMongoDbRepository(); store.Resource = obj.ClassName; store.Insert(obj); store.Delete(obj.ObjectId); var result = store.Get(obj.ObjectId); Assert.IsNull(result); }
public static Task SaveAsync(this RushObject obj) { return(SaveAsync(obj, CancellationToken.None)); }
public static IDictionary <string, object> AsDictionary(this RushObject obj) { return(obj.GetPropertyValues().ToDictionary(p => p.Key, p => p.Value)); }