Пример #1
0
        public void Int()
        {
            MockSetupRepository = new MockDbRepository();
            CompilerMock = new Mock<ICompilerService>();
            solutionController = new SolutionController(MockSetupRepository.Repository, CompilerMock.Object);
            var config = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/Solutions");
            var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "products" } });

            solutionController.ControllerContext = new HttpControllerContext(config, routeData, request);
            solutionController.Request = request;
            solutionController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
            AutoMapperConfiguration.Configure();
        }
Пример #2
0
        public void Int()
        {
            IQueryable<UnitTestSolution> SolutionList = new HashSet<UnitTestSolution>
            {
                new UnitTestSolution() {Id = 1, SetupSolutionId = 1, SetupSolution = new SetupSolution(){ Id = 1, Name = "S1"} },
                new UnitTestSolution() {Id = 2, SetupSolutionId = 2, SetupSolution = new SetupSolution(){ Id = 2, Name = "S2"} },
                new UnitTestSolution() {Id = 3, SetupSolutionId = 3, SetupSolution = new SetupSolution(){ Id = 3, Name = "S3"} },
                new UnitTestSolution() {Id = 4, SetupSolutionId = 4, SetupSolution = new SetupSolution(){ Id = 4, Name = "S4"} },
                new UnitTestSolution() {Id = 5, SetupSolutionId = 5, SetupSolution = new SetupSolution(){ Id = 5, Name = "S5"} }
            }.AsQueryable();

            MockDbRepository = new MockDbRepository();
            MockDbRepository.Mock.Setup(x => x.GetUnitTestSolutions(It.IsAny<bool>())).Returns(SolutionList);

            AutoMapperConfiguration.Configure();
            unitTestController = new UnitTestController(MockDbRepository.Mock.Object);
        }