Example #1
0
        public void CanNotCreateNullReferencePortfolio()
        {
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.CreatePortfolio(null, "");
        }
Example #2
0
        public void CanNotCreatePortfolioWithPercenWinsLessThanZero()
        {
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.CreatePortfolio(new PortfolioDTO {
                PercentWins = -1
            }, "");
        }
Example #3
0
        public void CanCreatePortfolio()
        {
            portfolioRepository.Setup(m => m.Create(It.IsAny <Portfolio>()))
            .Callback <Portfolio>(ListPortfolios.Add);
            customerService.Setup(m => m.GetCustomerByProfileId(It.IsAny <string>()))
            .Returns(new Customer {
                Id = 23123, Name = "Misha"
            });
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.CreatePortfolio(new PortfolioDTO(), "");

            Assert.IsTrue(ListPortfolios.Count() == 3);
        }
        public async Task CreateTest()
        {
            var name   = "Тестовый портфель 2";
            var result = await _portfolioService.CreatePortfolio(name, 1);

            Assert.IsTrue(result.IsSuccess);

            var containsPortfolio = await
                                    _financeDataService.EfContext.Portfolios.AnyAsync(p => p.Name == name && p.UserId == 1);

            Assert.IsTrue(containsPortfolio);
        }
        public async Task CreatePortfolioTest()
        {
            // Arrange
            using var dbContext = new ApplicationDbContext(_options);
            var portfolioService = new PortfolioService(dbContext, _logger.Object);

            var newPortfolioId = Guid.NewGuid();
            var newPortfolio   = new Portfolio
            {
                Id    = newPortfolioId,
                Name  = "New Portfolio",
                Owner = dbContext.Users.Find(user2Id)
            };

            // Act
            var result = await portfolioService.CreatePortfolio(newPortfolio, user2Id);

            // Assert
            Assert.AreEqual(newPortfolioId, result.Id);
            Assert.AreEqual("New Portfolio", result.Name);
        }