Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }