Exemplo n.º 1
0
        public async Task Update_Release(int monthRef, int yearRef, decimal amount, string transactionId)
        {
            string databaseName = "Update_Release";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultRelease(context, transactionId : transactionId);

                var    releaseTest = context.Release.FirstOrDefault();
                string releaseId   = releaseTest.Id;
                context.Entry(releaseTest).State = EntityState.Detached;
                IReleaseBO releaseBO = new ReleaseBO(context, null);
                Release    release   = new Release
                {
                    Id            = releaseId,
                    MonthRef      = monthRef,
                    YearRef       = yearRef,
                    Amount        = amount,
                    TransactionId = transactionId
                };
                int result = await releaseBO.Update(releaseId, release);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 2
0
        public async Task Update_Expense(string userId)
        {
            string databaseName = "Update_Expense";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransaction(context, userId);

                var    transactionTest = context.Transaction.FirstOrDefault();
                string transactionId   = transactionTest.Id;
                context.Entry(transactionTest).State = EntityState.Detached;
                ITransactionBO transactionBO = new TransactionBO(context, null);
                Transaction    transaction   = new Transaction
                {
                    Id            = transactionId,
                    Description   = "Teste",
                    DtTransaction = DateTime.Now,
                    YearRef       = 2020,
                    MonthRef      = 04,
                    Amount        = 200,
                    CategorieId   = "123",
                    UserId        = userId,
                    TypeId        = "123"
                };
                int result = await transactionBO.Update(transactionId, transaction);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 3
0
        public async Task Get()
        {
            try
            {
                await _context.GetContext();

                var controller = new CartController(_context.Context, MockHelper.MockHttpContextAccessor(_context.Context), MockHelper.MockLogger <CartController>());

                var result = await controller.Get();

                result.Should().BeOfType <OkObjectResult>();
            }
            finally
            {
                _context.Close();
            }
        }
Exemplo n.º 4
0
        public async Task Create_New_Categorie(string name, string userId)
        {
            string databaseName = "Create_New_Categorie";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                int result = await SaveDefaultCategories(context, userId, name);

                Assert.AreEqual(result, 1);
            }
        }
        public async Task GetMovies()
        {
            try
            {
                await _context.GetContext();

                var controller = new CinemaworldController(_context.Context, MockHelper.MockLogger <CinemaworldController>());
                var request    = new MovieRequest {
                    Page = 2, PageSize = 5
                };

                var result = await controller.GetMovies(request);

                result.Should().BeOfType <OkObjectResult>();
            }
            finally
            {
                _context.Close();
            }
        }
Exemplo n.º 6
0
        public async Task Create_New_TransactionType(string name)
        {
            string databaseName = "Create_New_Type";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                int result = await SaveDefaultTransactionType(context, name);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 7
0
        public async Task GetByUserId_Return_A_IEnumerable(string userId)
        {
            string databaseName = "GetByUserId_Return_A_IEnumerable";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultCategories(context, userId);

                ICategorieBO categorieBO = new CategorieBO(context, null);
                var          result      = await categorieBO.GetByUserId(userId);

                var type = typeof(IEnumerable <Categorie>);
                Assert.IsInstanceOf(type, result);
            }
        }
Exemplo n.º 8
0
        public async Task GetAll_Return_IEnumerable()
        {
            string databaseName = "GetAll_Return_A_IEnumerable";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransactionType(context);

                ITransactionTypeBO transactionTypeBO = new TransactionTypeBO(context, null);
                var result = await transactionTypeBO.GetAll();

                var type = typeof(IEnumerable <TransactionType>);
                Assert.IsInstanceOf(type, result);
            }
        }
Exemplo n.º 9
0
        public async Task GetByTransactionId_Return_A_IEnumerable(string transactionId)
        {
            string databaseName = "GetByTransactionId_Return_A_IEnumerable";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultRelease(context, transactionId);

                IReleaseBO releaseBO = new ReleaseBO(context, null);
                var        result    = await releaseBO.GetByTransactionId(transactionId);

                var type = typeof(IEnumerable <Release>);
                Assert.IsInstanceOf(type, result);
            }
        }
Exemplo n.º 10
0
        public async Task GetByUserId_Return_A_Limit(string userId, int limit)
        {
            string databaseName = "GetByUserId_Return_A_Limit";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransaction(context, userId : userId);

                ITransactionBO transactionBO = new TransactionBO(context, null);
                var            result        = await transactionBO.GetByUserId(userId, limit);

                int resultCount = result.Count();
                Assert.LessOrEqual(resultCount, limit, "Result is nos less o equal");
            }
        }
Exemplo n.º 11
0
        public async Task GetByUserId_Return_A_IEnumerable(string userId, int limit)
        {
            string databaseName = "GetByUserId_Return_A_IEnumerable";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransaction(context, userId : userId);

                ITransactionBO transactionBO = new TransactionBO(context, null);
                var            result        = await transactionBO.GetByUserId(userId, limit);

                var type = typeof(IEnumerable <Transaction>);
                Assert.IsInstanceOf(type, result);
            }
        }
Exemplo n.º 12
0
        public async Task GetById_Retunr_TransactionType()
        {
            string databaseName = "GetById_Retunr_TransactionType";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransactionType(context);

                ITransactionTypeBO transactionTypeBO = new TransactionTypeBO(context, null);
                string             typeId            = context.TransactionType.FirstOrDefault().Id;
                var result = await transactionTypeBO.GetById(typeId);

                var type = typeof(TransactionType);
                Assert.IsInstanceOf(type, result);
            }
        }
Exemplo n.º 13
0
        public async Task Delete()
        {
            string databaseName = "Delete";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransactionType(context);

                var    tType  = context.TransactionType.FirstOrDefault();
                string typeId = tType.Id;
                context.Entry(tType).State = EntityState.Detached;
                ITransactionTypeBO transactionTypeBO = new TransactionTypeBO(context, null);
                var result = await transactionTypeBO.Delete(typeId);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 14
0
        public async Task Post(CustomerRegistrationViewModel mockModel)
        {
            try
            {
                await _context.GetContext();

                var controller = new AccountsController(MockHelper.GetUserManager(new UserStore <AppUser>(_context.Context)), MockHelper.Mapper.Value, _context.Context, MockHelper.MockLogger <AccountsController>());

                var result = await controller.Post(mockModel);

                result.Should().BeOfType <OkObjectResult>().Which.Value.Should().Be("Account created");
            }
            finally
            {
                _context.Close();
            }
        }
Exemplo n.º 15
0
        public async Task Delete_With_Id(string transactionId)
        {
            string databaseName = "Delete_With_Id";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultRelease(context, transactionId);

                var    releaseTest = context.Release.FirstOrDefault();
                string releaseId   = releaseTest.Id;
                context.Entry(releaseTest).State = EntityState.Detached;
                IReleaseBO releaseBO = new ReleaseBO(context, null);
                var        result    = await releaseBO.Delete(releaseId);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 16
0
        public async Task Delete_With_Id(string userId)
        {
            string databaseName = "Delete_With_Id";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultTransaction(context, userId);

                var    transactionTest = context.Transaction.FirstOrDefault();
                string transactionId   = transactionTest.Id;
                context.Entry(transactionTest).State = EntityState.Detached;
                ITransactionBO transactionBO = new TransactionBO(context, null);
                var            result        = await transactionBO.Delete(transactionId);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 17
0
        public async Task Delete_With_Id(string userId)
        {
            string databaseName = "Delete_With_Id";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultCategories(context, userId);

                var    categorieTest = context.Categorie.FirstOrDefault();
                string categorieId   = categorieTest.Id;
                context.Entry(categorieTest).State = EntityState.Detached;
                ICategorieBO categorieBO = new CategorieBO(context, null);
                var          result      = await categorieBO.Delete(categorieId);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 18
0
        public async Task Create_New_Release(int monthRef, int yearRef, decimal amount, string transactionId)
        {
            string databaseName = "Create_New_Release";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                Release release = new Release
                {
                    MonthRef      = monthRef,
                    YearRef       = yearRef,
                    Amount        = amount,
                    TransactionId = transactionId
                };
                int result = await SaveDefaultRelease(context, release : release);

                Assert.AreEqual(result, 1);
            }
        }
Exemplo n.º 19
0
        public async Task Post(AppUser mockUser, CredentialsViewModel mockModel)
        {
            try
            {
                await _context.GetContext();

                var controller = new AuthController(MockHelper.MockUserManager(mockUser), MockHelper.MockJwtFactory(), MockHelper.MockJwtoptions(), MockHelper.MockLogger <AuthController>());
                mockModel.Password = mockModel.Password.Substring(12);

                var result = await controller.Post(mockModel);

                result.Should().BeOfType <OkObjectResult>();
            }
            finally
            {
                _context.Close();
            }
        }
Exemplo n.º 20
0
        public async Task Update_Categorie(string name, string userId)
        {
            string databaseName = "Update_Categorie";

            using (var context = DataBaseContext.GetContext(databaseName))
            {
                await SaveDefaultCategories(context, userId);

                var    categorieTest = context.Categorie.FirstOrDefault();
                string categorieId   = categorieTest.Id;
                context.Entry(categorieTest).State = EntityState.Detached;
                ICategorieBO categorieBO = new CategorieBO(context, null);
                Categorie    categorie   = new Categorie
                {
                    Id     = categorieId,
                    Name   = name,
                    UserId = userId
                };
                int result = await categorieBO.Update(categorieId, categorie);

                Assert.AreEqual(result, 1);
            }
        }