Beispiel #1
0
        public async Task MemberService_GetPoints_ShouldReturnSucceedFalse_WhenExceptionOccurs()
        {
            // arrange

            var database = new SkyraDatabase(GetSubstitute(), new NullLogger <SkyraDatabase>());

            // act

            var result = await database.GetUserPointsAsync("testing1");

            // assert

            Assert.IsFalse(result.Success);
        }
        public async Task SkyraDatabase_GetUserPoints_ShouldReturnZero_WhenUserDoesNotExist()
        {
            // arrange
            await using var database = new SkyraDatabase(Utils.GetContext(), new NullLogger <SkyraDatabase>());
            const string id = "testing1";

            // act

            var result = await database.GetUserPointsAsync(id);

            // assert

            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Value);
        }
        public async Task SkyraDatabase_AddUserPoints_ShouldReturnSamePoints_WhenUserDoesNotExist(int points)
        {
            // arrange
            await using var database = new SkyraDatabase(Utils.GetContext(), new NullLogger <SkyraDatabase>());
            const string id = "testing1";

            // act

            var firstResult = await database.AddUserPointsAsync(id, points);

            var finalResult = await database.GetUserPointsAsync(id);

            // assert

            Assert.IsTrue(firstResult.Success);
            Assert.IsTrue(finalResult.Success);
            Assert.AreEqual(points, finalResult.Value);
        }