Example #1
0
        public async Task LoginCodeTest(string token, string appKey, string device, bool exception, Type exceptionType = null)
        {
            var tokenRep      = TokenRepositoryMock.CreateRepository();
            var userRep       = UserRepositoryMock.CreateRepository();
            var tokenExtactor = TokenInfoExtractorMock.Create();

            try
            {
                await GetTokenInfo.Execute(tokenRep, userRep, tokenExtactor, token, appKey, device);

                Assert.IsFalse(exception);
            }
            catch (Exception ex)
            {
                Assert.IsTrue((exception) && (exceptionType.FullName == ex.GetType().FullName));
            }
        }
Example #2
0
        public async Task CreateUserFlowTest(string token, string appKey, string device, bool callGetUserIdByTokenCount, bool callGetByIdCount)
        {
            var tokenRep      = TokenRepositoryMock.CreateRepository();
            var userRep       = UserRepositoryMock.CreateRepository();
            var tokenExtactor = TokenInfoExtractorMock.Create();

            try
            {
                await GetTokenInfo.Execute(tokenRep, userRep, tokenExtactor, token, appKey, device);

                Assert.AreEqual(userRep.GetByIdCount, callGetByIdCount ? 1 : 0);
                Assert.AreEqual(tokenRep.GetUserIdByTokenCount, callGetUserIdByTokenCount ? 1 : 0);
            }
            catch
            {
                Assert.AreEqual(userRep.GetByIdCount, callGetByIdCount ? 1 : 0);
                Assert.AreEqual(tokenRep.GetUserIdByTokenCount, callGetUserIdByTokenCount ? 1 : 0);
            }
        }
Example #3
0
        public async Task GetTokenInfoInvalidParametersTest(bool isTokenRepNull, bool isUserRepNull, bool isTokenExtractorNull, string token, string appKey, string device)
        {
            var tokenRep       = isTokenRepNull ? null : TokenRepositoryMock.CreateRepository();
            var userRep        = isUserRepNull ? null : UserRepositoryMock.CreateRepository();
            var tokenExytactor = isTokenExtractorNull ? null : TokenInfoExtractorMock.Create();

            try
            {
                await GetTokenInfo.Execute(tokenRep, userRep, tokenExytactor, token, appKey, device);

                Assert.Fail();
            }
            catch (Exception ex)
            {
                if (isTokenRepNull || isUserRepNull || isTokenExtractorNull)
                {
                    Assert.AreEqual(ex.GetType(), typeof(ArgumentNullException));
                }
                else
                {
                    Assert.AreEqual(ex.GetType(), typeof(ArgumentException));
                }
            }
        }