public async Task UserClient_GetPoints_ToUserThatDoesExist_ReturnsPoints() { // arrange var amount = Rng.Next(); var channel = GetChannel(); var client = new User.UserClient(channel); const string id = "1"; var addQuery = new UserPointsQuery { Id = id, Amount = amount }; var getQuery = new UserQuery { Id = id }; // act var addResult = await client.AddPointsAsync(addQuery); var getResult = await client.GetPointsAsync(getQuery); // assert Assert.AreEqual(Status.Success, addResult.Status, "AddPoints() failed."); Assert.AreEqual(Status.Success, getResult.Status, "GetPoints() failed."); Assert.AreEqual(amount, getResult.Amount); }
public async Task UserClient_RemovePoints_ToUserThatDoesNotExist_SetsToZero() { // arrange var channel = GetChannel(); var client = new User.UserClient(channel); const string id = "1"; var removeQuery = new UserPointsQuery { Id = id, Amount = 100 }; var getQuery = new UserQuery { Id = id }; // act var removeResult = await client.RemovePointsAsync(removeQuery); var getResult = await client.GetPointsAsync(getQuery); // assert Assert.AreEqual(Status.Success, removeResult.Status, "RemovePoints() failed."); Assert.AreEqual(Status.Success, getResult.Status, "GetPoints() failed."); Assert.AreEqual(0, getResult.Amount); }
public async Task UserClient_GetPoints_ToUserThatDoesNotExist_ReturnsZero() { // arrange var channel = GetChannel(); var client = new User.UserClient(channel); var getQuery = new UserQuery { Id = "1" }; // act var getResult = await client.GetPointsAsync(getQuery); // assert Assert.AreEqual(Status.Success, getResult.Status, "GetPoints() failed."); Assert.AreEqual(0, getResult.Amount); }
public async Task UserClient_RemovePoints_ToUserThatHasMoney_ReturnsCorrectAmount() { // arrange var channel = GetChannel(); var client = new User.UserClient(channel); const string id = "1"; const int startingAmount = 100; const int removeAmount = 20; var addQuery = new UserPointsQuery { Id = id, Amount = startingAmount }; var removeQuery = new UserPointsQuery { Id = id, Amount = removeAmount }; var getQuery = new UserQuery { Id = id }; // act var addResult = await client.AddPointsAsync(addQuery); var removeResult = await client.RemovePointsAsync(removeQuery); var getResult = await client.GetPointsAsync(getQuery); // assert Assert.AreEqual(Status.Success, addResult.Status, "AddPoints() failed."); Assert.AreEqual(Status.Success, removeResult.Status, "RemovePoints() failed."); Assert.AreEqual(Status.Success, getResult.Status, "GetPoints() failed."); Assert.AreEqual(startingAmount - removeAmount, getResult.Amount); }
public async Task UserClient_ResetPoints_ToUserThatDoesNotExist_RemovesAllPoints() { // arrange var amount = Rng.Next(); var channel = GetChannel(); var client = new User.UserClient(channel); const string id = "1"; var userQuery = new UserQuery { Id = id }; // act var resetResult = await client.ResetPointsAsync(userQuery); var getResult = await client.GetPointsAsync(userQuery); // assert Assert.AreEqual(Status.Success, resetResult.Status, "ResetPoints() failed."); Assert.AreEqual(Status.Success, getResult.Status, "GetPoints() failed."); Assert.AreEqual(0, getResult.Amount); }