Skip to content

Commit

Permalink
Test case updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro committed Aug 1, 2017
1 parent 052f135 commit b2226bc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Nakama.Tests/SimpleMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void GetConfig()
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.StatusDescription);
Assert.That(result, Contains.Substring("name"));
Assert.That(result, Contains.Substring("port"));
Assert.That(result, Contains.Substring("dashboard_port"));
Assert.That(result, Contains.Substring("db"));
Assert.That(result, Contains.Substring("dashboard"));
Assert.That(result, Contains.Substring("database"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Nakama.Tests/SimpleServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void UnrecognisedContentType()
request.ContentType = "application/json;";
request.Accept = "application/json;";
var response = extractBadResponse(request);
Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode, response.StatusDescription);
Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode, response.StatusDescription);
}

[Test]
Expand Down
75 changes: 37 additions & 38 deletions Nakama.Tests/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,38 +207,6 @@ public void FetchStorage()
}

[Test, Order(5)]
public void UpdateStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
INResultSet<INStorageKey> res = null;

var jsonString = "{\"coins\": 100, \"gems\": 10, \"artifacts\": 0}";
byte[] json = Encoding.UTF8.GetBytes(jsonString);

var message = new NStorageUpdateMessage.Builder()
.Update(Bucket, Collection, Record, new NStorageUpdateMessage.StorageUpdateBuilder()
.Init("/foo", json) // make sure record is setup.
.Incr("/foo/coins", -10) // perform other updates to the record.
.Build())
.Build();
client.Send(message, (INResultSet<INStorageKey> results) =>
{
res = results;
evt.Set();
}, (INError err) => {

evt.Set();
});

evt.WaitOne(1000, false);
Assert.IsNotNull(res);
Assert.IsNotEmpty(res.Results);
Assert.AreEqual(Bucket, res.Results[0].Bucket);
Assert.AreEqual(Collection, res.Results[0].Collection);
Assert.AreEqual(Record, res.Results[0].Record);
}

[Test, Order(6)]
public void ListStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand Down Expand Up @@ -272,7 +240,7 @@ public void ListStorage()
Assert.AreEqual(StorageValue, storageData.Results[0].Value);
}

[Test, Order(7)]
[Test, Order(6)]
public void RemoveStorageInvalidIfMatch()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand All @@ -297,7 +265,7 @@ public void RemoveStorageInvalidIfMatch()
Assert.AreEqual("Storage remove rejected: not found, version check failed, or permission denied", error.Message);
}

[Test, Order(8)]
[Test, Order(7)]
public void RemoveStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand All @@ -317,7 +285,7 @@ public void RemoveStorage()
Assert.IsTrue(committed);
}

[Test, Order(9)]
[Test, Order(8)]
public void WritePublicStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand All @@ -342,7 +310,7 @@ public void WritePublicStorage()
Assert.AreEqual(Record, res.Results[0].Record);
}

[Test, Order(10)]
[Test, Order(9)]
public void ReadPublicStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand Down Expand Up @@ -374,7 +342,7 @@ public void ReadPublicStorage()
Assert.AreEqual(StorageValue, storageData.Results[0].Value);
}

[Test, Order(11)]
[Test, Order(10)]
public void ReadPublicStorageOtherUsers()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand Down Expand Up @@ -416,7 +384,7 @@ public void ReadPublicStorageOtherUsers()
Assert.AreEqual(StorageValue, storageData.Results[0].Value);
}

[Test, Order(12)]
[Test, Order(11)]
public void RemovePublicStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
Expand All @@ -435,5 +403,36 @@ public void RemovePublicStorage()
evt.WaitOne(1000, false);
Assert.IsTrue(committed);
}

[Test, Order(12)]
public void UpdateStorage()
{
ManualResetEvent evt = new ManualResetEvent(false);
INResultSet<INStorageKey> res = null;

var jsonString = "{\"coins\": 100, \"gems\": 10, \"artifacts\": 0}";
byte[] json = Encoding.UTF8.GetBytes(jsonString);

var message = new NStorageUpdateMessage.Builder()
.Update(Bucket, Collection, Record, new NStorageUpdateMessage.StorageUpdateBuilder()
.Init("/foo", json) // make sure record is setup.
.Incr("/foo/coins", -10) // perform other updates to the record.
.Build())
.Build();
client.Send(message, (INResultSet<INStorageKey> results) =>
{
res = results;
evt.Set();
}, (INError err) => {
evt.Set();
});

evt.WaitOne(1000, false);
Assert.IsNotNull(res);
Assert.IsNotEmpty(res.Results);
Assert.AreEqual(Bucket, res.Results[0].Bucket);
Assert.AreEqual(Collection, res.Results[0].Collection);
Assert.AreEqual(Record, res.Results[0].Record);
}
}
}

0 comments on commit b2226bc

Please sign in to comment.