Пример #1
0
        public async Task AccountInfo_Successes(int accountId, double ammount)
        {
            var testee = new AccountInfoAsync(accountId, moq.Object);
            await testee.RefreshAmountAsync();

            Assert.Equal(ammount, testee.Amount);
            moq.Verify(x => x.GetAccountAmountAsync(accountId));
        }
Пример #2
0
        public async Task AccountInfo_SuccessesfulLocked()
        {
            var testee = new AccountInfoAsync(5, moq.Object);
            var tasks  = Enumerable.Range(0, 3).
                         Select(x => testee.RefreshAmountAsync());

            await Task.WhenAll(tasks);

            moq.Verify(x => x.GetAccountAmountAsync(5), Times.Once());
            Assert.Equal(32, testee.Amount);
        }
Пример #3
0
        public async Task AccountInfo_MultipleCalls()
        {
            var testee = new AccountInfoAsync(5, moq.Object);

            await testee.RefreshAmountAsync();

            await testee.RefreshAmountAsync();

            await testee.RefreshAmountAsync();

            moq.Verify(x => x.GetAccountAmountAsync(5), Times.Exactly(3));
            Assert.Equal(32, testee.Amount);
        }
Пример #4
0
        public void AccouuntInfo_Amount_DidntChange(int accountId)
        {
            var testee = new AccountInfoAsync(accountId, moq.Object);

            Assert.Equal(0, testee.Amount);
        }
Пример #5
0
        public void AccountInfo_Fail(int accountId)
        {
            var testee = new AccountInfoAsync(accountId, moq.Object);

            Assert.ThrowsAsync <InvalidOperationException>(() => testee.RefreshAmountAsync());
        }