示例#1
0
        public async Task UserClient_AddPoints_ToUserThatDoesExist_ReturnsExtraPoints()
        {
            // arrange
            var startingAmount   = Rng.Next();
            var additionalAmount = Rng.Next();

            var          channel = GetChannel();
            var          client  = new User.UserClient(channel);
            const string id      = "1";

            var createQuery = new UserPointsQuery
            {
                Id     = id,
                Amount = startingAmount
            };

            var addQuery = new UserPointsQuery
            {
                Id     = id,
                Amount = additionalAmount
            };

            // act
            var createResult = await client.AddPointsAsync(createQuery);

            var addResult = await client.AddPointsAsync(addQuery);

            // assert
            Assert.AreEqual(Status.Success, createResult.Status, "AddPoints() failed.");
            Assert.AreEqual(Status.Success, addResult.Status, "AddPoints() failed.");
            Assert.AreEqual(startingAmount + additionalAmount, addResult.Amount);
        }
示例#2
0
        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);
        }
示例#3
0
        // Tyler doesn't get we validate in Skyra, not in here.
        // [Test]
        public async Task UserClient_RemovePoints_WithNegativeAmount_ReturnsFailedStatus()
        {
            // arrange
            var          channel = GetChannel();
            var          client  = new User.UserClient(channel);
            const string id      = "1";

            var addQuery = new UserPointsQuery
            {
                Id     = id,
                Amount = -10
            };

            // act
            var addResult = await client.AddPointsAsync(addQuery);

            // assert
            Assert.AreEqual(Status.Failed, addResult.Status, "AddPoints() did not fail.");
        }
示例#4
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);
        }
示例#5
0
        public async Task UserClient_AddPoints_ToUserThatDoesNotExist_ReturnsSamePoints()
        {
            // arrange
            var amount = Rng.Next();

            var          channel = GetChannel();
            var          client  = new User.UserClient(channel);
            const string id      = "1";

            var query = new UserPointsQuery
            {
                Id     = id,
                Amount = amount
            };

            // act
            var result = await client.AddPointsAsync(query);

            // assert
            Assert.AreEqual(Status.Success, result.Status, "AddPoints() failed.");
            Assert.AreEqual(amount, result.Amount);
        }