public async Task CannotPurchaseMoreThanMontlyLimit() { AddDefaultCurrency(); SetupCurrencyService(); _db.Purchases.Add(new Purchase { UserId = userId, CurrencyId = currencyId, Quantity = monthlyLimit }); _db.SaveChanges(); _purchaseServices = new PurchaseServices(_db, currencyServices.Object); var result = await _purchaseServices.PostPurchase(new PurchaseDto { UserId = userId, CurrencyId = currencyId, Quantity = 100 }); Assert.IsNotNull(result); var okResult = result as BadRequestObjectResult; Assert.IsNotNull(okResult); var apiResponse = okResult.Value as ApiResponseDto; Assert.IsFalse(apiResponse.Success); Assert.IsTrue(apiResponse.Message == $"Purchase limit for this currency is {monthlyLimit} by month"); }
public async Task MakePurchaseAsync() { AddDefaultCurrency(); SetupCurrencyService(); _purchaseServices = new PurchaseServices(_db, currencyServices.Object); var result = await _purchaseServices.PostPurchase(new PurchaseDto { UserId = userId, CurrencyId = currencyId, Quantity = 100 }); Assert.IsNotNull(result); var okResult = result as OkObjectResult; Assert.IsNotNull(okResult); var apiResponse = okResult.Value as ApiResponseDto; Assert.IsTrue(apiResponse.Success); }