コード例 #1
0
ファイル: TestingApiVk.cs プロジェクト: DenchickDev/Testing4
        public void GetPopularAppFromServiceTest()//тест app сервиса с помощью мок репозитория
        {
            IAppRepository appRepository = new AppRepositoryMock();
            AppService     appService    = new AppService(appRepository);

            string popular = appService.GetPopularAppVk("4063926");

            Assert.AreEqual("Очень популярно", popular);

            popular = appService.GetPopularAppVk("4063927");
            Assert.AreEqual("Непопулярно", popular);

            popular = appService.GetPopularAppVk("4063928");
            Assert.AreEqual("Популярно", popular);
        }
コード例 #2
0
        public async Task CreateAppInvalidParametersTest(string appName, bool isRepNull)
        {
            var rep = isRepNull ? null : AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.GetType(), isRepNull ? typeof(ArgumentNullException) : typeof(ArgumentException));
            }
        }
コード例 #3
0
        public async Task CreateAppTest(string appName, bool exception, Type exceptionType = null)
        {
            var rep = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.IsFalse(exception);
            }
            catch (Exception ex)
            {
                Assert.IsTrue((exception) && (exceptionType.FullName == ex.GetType().FullName));
            }
        }
コード例 #4
0
ファイル: CreateUserTests.cs プロジェクト: uiralima/raique
        public async Task CreateUserTest(string appKey, string userName, string password, bool exception, Type exceptionType = null)
        {
            var userRep = UserRepositoryMock.CreateRepository();
            var appRep  = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateUser.Execute(appRep, userRep, appKey, userName, password);

                Assert.IsFalse(exception);
            }
            catch (Exception ex)
            {
                Assert.IsTrue((exception) && (exceptionType.FullName == ex.GetType().FullName));
            }
        }
コード例 #5
0
        public async Task CreateAppFlowTest(string appName, bool incCreate, bool incGetByName)
        {
            var rep = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.AreEqual(rep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(rep.GetByNameCount, incGetByName ? 1 : 0);
            }
            catch
            {
                Assert.AreEqual(rep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(rep.GetByNameCount, incGetByName ? 1 : 0);
            }
        }
コード例 #6
0
ファイル: CreateUserTests.cs プロジェクト: uiralima/raique
        public async Task CreateUserFlowTest(string appKey = "", string userName = "", string password = "", bool incCreate = false, bool incGetByKeyToAppCount = false, bool incAppGetByKey = false)
        {
            var userRep = UserRepositoryMock.CreateRepository();
            var appRep  = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateUser.Execute(appRep, userRep, appKey, userName, password);

                Assert.AreEqual(userRep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(userRep.GetByKeyToAppCount, incGetByKeyToAppCount ? 1 : 0);
                Assert.AreEqual(appRep.GetByKeyCount, incAppGetByKey ? 1 : 0, "Não deveria ter chamado a verificação de app");
            }
            catch
            {
                Assert.AreEqual(userRep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(userRep.GetByKeyToAppCount, incGetByKeyToAppCount ? 1 : 0);
                Assert.AreEqual(appRep.GetByKeyCount, incAppGetByKey ? 1 : 0, "Não deveria ter chamado a verificação de app");
            }
        }
コード例 #7
0
ファイル: CreateUserTests.cs プロジェクト: uiralima/raique
        public async Task CreateUserInvalidParametersTest(bool isAppRepNull, bool isUserRepNull, string key = "", string userName = "", string password = "")
        {
            var appRep  = isAppRepNull ? null : AppRepositoryMock.CreateRepository();
            var userRep = isUserRepNull ? null : UserRepositoryMock.CreateRepository();

            try
            {
                await CreateUser.Execute(appRep, userRep, key, userName, password);

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