Пример #1
0
        public async Task CreateDuplicateSession()
        {
            await Service.NewSessionAsync(2UL, ValidUser, 0UL, 10);

            await Assext.ThrowsRootAsync <DuplicateSessionException>(
                () => Service.NewSessionAsync(2UL, ValidUser, 0UL, 10));
        }
Пример #2
0
        public async Task InvalidSelfTransferTest()
        {
            var unit        = NewContext();
            var userService = new UserService(unit, null);

            var service = new TransactionService(userService);
            await Assext.ThrowsRootAsync <UserNullException>(
                async() => await service.CreateTransactionAsync(new TransactionRequest(1L, 1L, 10)));
        }
Пример #3
0
        public async Task InvalidCurrencyTransferTest()
        {
            var unit        = NewContext();
            var userService = new UserService(unit, null);

            // TODO: replace with better testing solution.
            bool ranCallback = false;

            var events = new TransactionEvents();

            events.OnTransactionFailed += (a, b) =>
            {
                Assert.IsType <InsufficientCurrencyException>(b);
                ranCallback = true;
                return(Task.CompletedTask);
            };

            var service = new TransactionService(userService, events);

            await Assext.ThrowsRootAsync <InsufficientCurrencyException>(
                async() => await service.CreateTransactionAsync(new TransactionRequest(2L, 1L, 10)));

            Assert.True(ranCallback, "TransactionService did not call error event");
        }
Пример #4
0
 public async Task LoadNullSession()
 {
     await Assext.ThrowsRootAsync <BlackjackSessionNullException>(
         () => Service.LoadSessionAsync(ValidUser, 1UL));
 }