Exemplo n.º 1
0
        public void TestConsultaTrackById()
        {
            var tasks = new List <Task>();

            var numRequisitions = 15;

            for (int i = 0; i < numRequisitions; i++)
            {
                tasks.Add(Task.Run(() =>
                {
                    using (var scope = container.BeginExecutionContextScope())
                    {
                        var repoUOW   = scope.GetInstance <IUnitOfWork>();
                        var repoMusic = scope.GetInstance <IMusicRepository>();

                        var controller = new MusicsController(repoUOW, repoMusic);

                        var actionResult = controller.GetAll();

                        var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <Music> >;

                        Assert.IsTrue(contentResult.Content.Count() > 0);
                    }
                }));
            }

            Task.WaitAll(tasks.ToArray());
        }
Exemplo n.º 2
0
        public void Test()
        {
            //var mockRepository = new Mock<IProductRepository>();
            //mockRepository.Setup(x => x.GetById(42))
            //    .Returns(new Product { Id = 42 });

            var tasks = new List <Task>();

            var numRequisitions = 20000;

            for (int i = 0; i < numRequisitions; i++)
            {
                tasks.Add(Task.Run(() =>
                {
                    using (container.BeginExecutionContextScope())
                    {
                        var repoUOW   = container.GetInstance <IUnitOfWork>();
                        var repoMusic = container.GetInstance <IMusicRepository>();


                        var controller = new MusicsController(repoUOW, repoMusic);

                        // Act
                        var actionResult = controller.GetAll();

                        var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <Music> >;

                        Assert.IsTrue(contentResult.Content.Count() > 0);
                    }
                }));
            }

            Task.WaitAll(tasks.ToArray());
        }