public async Task ThrowsNotValidDayInMonthException_WhenDayIsBiggerThen31()
        {
            var casinoContextMock     = new Mock <CasinoContext>();
            var adminDashboardService = new AdminDashboardService(casinoContextMock.Object);

            await Assert.ThrowsExceptionAsync <NotValidDayInMonthException>(() => adminDashboardService.GetTransactionsCurrencyDaylyWins(32));
        }
        public async Task ReturnResultOne()
        {
            var contextOptions = new DbContextOptionsBuilder <CasinoContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnZeroCount")
                                 .Options;

            var type = "Win";

            var transactionType = new TransactionType()
            {
                Id   = 1,
                Name = type
            };

            var transaction = new Transaction()
            {
                TransactionType = transactionType
            };

            using (var context = new CasinoContext(contextOptions))
            {
                context.Transactions.Add(transaction);
                await context.SaveChangesAsync();

                var adminService = new AdminDashboardService(context);

                var result = await adminService.GetTotaTransactionsByTypeCount(type);

                Assert.AreEqual(1, result);
            }
        }
        public async Task ThrowExceptionArgumentNullException_WhenParameterTypeIsNull()
        {
            var casinoContextMock = new Mock <CasinoContext>();

            string transactionType = null;

            var adminDashboardService = new AdminDashboardService(casinoContextMock.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => adminDashboardService.GetTotaTransactionsByTypeCount(transactionType));
        }
Пример #4
0
        public async Task ThrowExceptionArgumentOutOfRangeException_WhenParameterMonthCountIsLessThenOne()
        {
            var casinoContextMock = new Mock <CasinoContext>();

            string   transactionType = "Win";
            DateTime date            = DateTime.Parse("12/12/2018");
            int      monthCount      = 0;

            var adminDashboardService = new AdminDashboardService(casinoContextMock.Object);

            await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(() => adminDashboardService.GetMonthsTransactions(date, transactionType, monthCount));
        }
Пример #5
0
        public async Task ReturnOneYearMontsValueByMonthDTO()
        {
            var contextOptions = new DbContextOptionsBuilder <CasinoContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnOneYearMontsValueByMonthDTO")
                                 .Options;

            using (var context = new CasinoContext(contextOptions))
            {
                var adminService = new AdminDashboardService(context);

                var date   = DateTime.Parse("12/14/2018");
                var result = await adminService.GetYearTransactions(date);

                Assert.AreEqual(12, result.ValuesByMonth.Count);
            }
        }
        public async Task ReturnDaylyTotalInBGN()
        {
            var contextOptions = new DbContextOptionsBuilder <CasinoContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnDaylyTotalInBGN")
                                 .Options;

            var normalisedAmount = 10;
            var transactionType  = new TransactionType()
            {
                Id   = 1,
                Name = "Win"
            };

            var wallet = new Wallet()
            {
                Currency = new Currency()
                {
                    Name = "BGN"
                }
            };
            var user = new User()
            {
                Wallet = wallet
            };

            var transaction = new Transaction()
            {
                CreatedOn        = DateTime.Now,
                TransactionType  = transactionType,
                User             = user,
                NormalisedAmount = normalisedAmount
            };

            var currentDay = DateTime.Now.Day;

            using (var context = new CasinoContext(contextOptions))
            {
                context.Transactions.Add(transaction);
                var adminService = new AdminDashboardService(context);
                await context.SaveChangesAsync();

                var result = await adminService.GetTransactionsCurrencyDaylyWins(currentDay);

                Assert.AreEqual(normalisedAmount, result.DaylyTotalUSD);
            }
        }
        public async Task ReturnZeroCount()
        {
            var contextOptions = new DbContextOptionsBuilder <CasinoContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnZeroCount")
                                 .Options;

            using (var context = new CasinoContext(contextOptions))
            {
                var adminService = new AdminDashboardService(context);

                var transactionType = "Win";

                var result = await adminService.GetTotaTransactionsByTypeCount(transactionType);

                Assert.AreEqual(0, result);
            }
        }
Пример #8
0
        public async Task ReturnThreeMontsValueByMonthDTO()
        {
            var contextOptions = new DbContextOptionsBuilder <CasinoContext>()
                                 .UseInMemoryDatabase(databaseName: "ReturnZeroValueByMonthDTO")
                                 .Options;

            using (var context = new CasinoContext(contextOptions))
            {
                var adminService = new AdminDashboardService(context);

                var      transactionType = "Win";
                DateTime date            = DateTime.Parse("12/12/2018");
                var      month           = 2;

                var result = await adminService.GetMonthsTransactions(date, transactionType, month);

                Assert.AreEqual(3, result.ValuesByMonth.Count);
            }
        }