/// <summary>
        /// Initializes a new instance of the <see cref="InvestmentsControllerTests"/> class.
        /// </summary>
        public InvestmentsControllerTests()
        {
            this.logger    = new Mock <ILogger <InvestmentsController> >();
            this.portfolio = new Mock <IPortfolioService>();

            this.sut = new InvestmentsController(this.logger.Object, this.portfolio.Object);
        }
        public async Task TestReturnAllInvestments()
        {
            InvestmentsController investmentsController = new InvestmentsController(LoadSampleDatabaseAndReturnContext());
            var result = await investmentsController.GetInvestments();

            //The result should be json and not null;
            Assert.IsNotNull(result);
        }
 public InvestmentsControllerTests()
 {
     this.optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>()
                           .UseInMemoryDatabase("investmentWalletsDatabase");
     this.db = new ApplicationDbContext(this.optionsBuilder.Options);
     this.currenciesService         = new CurrenciesService(this.db);
     this.investmentsWalletsService = new InvestmentsWalletsService(this.db);
     this.userManager = new FakeUserManager();
     this.controller  = new InvestmentsController(this.currenciesService, this.investmentsWalletsService, this.userManager);
 }
        public async Task TestReturnSpecificInvestment()
        {
            //Get the investment details about Peleton

            InvestmentsController investmentsController = new InvestmentsController(LoadSampleDatabaseAndReturnContext());
            var result = await investmentsController.GetInvestmentDetails(5);

            //The result should be json and not null;
            Assert.IsNotNull(result);
        }
        public InvestmentsControllerTests(ITestOutputHelper ouput)
        {
            // Arrange
            ServiceProvider serviceProvider = TestServiceProvider.GetProvider();

            configuration = serviceProvider.GetService <IConfiguration>();
            clientFactory = serviceProvider.GetService <IHttpClientFactory>();
            this.output   = ouput;
            controller    = new InvestmentsController(configuration, clientFactory);
        }
Exemple #6
0
        public void Index_StateUnderTest_ExpectedBehavior(string Id)
        {
            // Arrange
            var controller = new InvestmentsController(configuration);

            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            controller.ControllerContext.HttpContext.Request.Headers["ApiKey"] = configuration["ApiKey"];

            // Act
            var result = controller.Index(Id) as OkObjectResult;

            // Assert
            Assert.Contains("AAPL", result.Value.ToString());
            output.WriteLine(result.Value.ToString());
        }
Exemple #7
0
 public InvestmentsControllerTest()
 {
     // arrange
     _repository = new FakeInvestmentPerformanceRepository();
     _controller = new InvestmentsController(_repository, new NullLogger <InvestmentsController>());
 }