public async Task UpdatePortfolio_With_Valid_Data_Correctly_Updates_Portfolio() { // Arrange using var dbContext = new ApplicationDbContext(_options); var portfolioService = new PortfolioService(dbContext, _logger.Object); // Act var portfolio = await portfolioService.GetPortfolioById(portfolio1Id); portfolio.Name = "Test Updated Name"; await portfolioService.UpdatePortfolio(portfolio); var result = await portfolioService.GetPortfolioById(portfolio1Id); // Assert Assert.AreEqual("Test Updated Name", result.Name); }
public async Task GetPortfolioById_For_Invalid_Id_Returns_Empty() { // Arrange using var dbContext = new ApplicationDbContext(_options); var portfolioService = new PortfolioService(dbContext, _logger.Object); // Act var result = await portfolioService.GetPortfolioById(Guid.NewGuid()); // Assert Assert.IsNull(result); }
public async Task GetPortfolioById_For_Valid_Id_Returns_Correct_Portfolio() { // Arrange using var dbContext = new ApplicationDbContext(_options); var portfolioService = new PortfolioService(dbContext, _logger.Object); // Act var result = await portfolioService.GetPortfolioById(portfolio1Id); // Assert Assert.AreEqual("Test 1", result.Name); }
public async Task DeletePortfolioTest() { // Arrange using var dbContext = new ApplicationDbContext(_options); var portfolioService = new PortfolioService(dbContext, _logger.Object); // Act var result = await portfolioService.DeletePortfolio(portfolio2Id); // Assert Assert.IsTrue(result); var portfolio = await portfolioService.GetPortfolioById(portfolio2Id); Assert.IsNull(portfolio); }