Пример #1
0
        public async Task PurchaseBackgroundAsync()
        {
            backgroundStoreMock.Setup(x => x.GetBackgroundAsync(It.IsAny <int>()))
            .Returns(new ValueTask <Background>(new Background {
                Id = 1, Price = 100
            }));
            backgroundsOwnedRepositoryMock.Setup(x => x.GetAsync(It.IsAny <long>(), It.IsAny <int>()))
            .Returns(new ValueTask <BackgroundsOwned>());

            await backgroundService.PurchaseBackgroundAsync(1L, 1);

            transactionServiceMock.Verify(
                x => x.CreateTransactionAsync(It.IsAny <TransactionRequest>()));
            backgroundsOwnedRepositoryMock.Verify(
                x => x.AddAsync(It.Is <BackgroundsOwned>(x => x.BackgroundId == 1 && x.UserId == 1L)));
            unitOfWorkMock.Verify(x => x.CommitAsync());
        }