예제 #1
0
        public void GetTest()
        {
            //Arrange
            Mock <ICandidateRepository> mockCandidateRepository = new Mock <ICandidateRepository>();

            mockCandidateRepository.Setup(x => x.GetAllCandidates()).Returns(CreateCandidates());
            CandidateController controller = new CandidateController(mockCandidateRepository.Object);

            //Act
            IHttpActionResult actionResult = controller.Get();
            var contentResult           = actionResult as OkNegotiatedContentResult <List <Candidate> >;
            List <Candidate> candidates = contentResult.Content ?? throw new ArgumentNullException("contentResult.Content");

            //Assert
            Assert.IsNotNull(candidates);
            Assert.AreEqual(candidates.Count, 9);
            int id = 1;

            for (int i = 0; i < candidates.Count; i++)
            {
                Assert.AreEqual(candidates[i].CandidateId, id.ToString());
                Assert.AreEqual(candidates[i].FirstName, $"FirstName{id.ToString()}");
                Assert.AreEqual(candidates[i].Surname, $"Surname{id.ToString()}");
                id++;
            }
        }
        public void Setup()
        {
            mockedCandidatedDataRepository = new Mock <ICandidateDataRepository>();
            mockedCompetencyDataRepository = new Mock <ICompetencyDataRepository>();
            candidateController            = new CandidateController(mockedCandidatedDataRepository.Object, mockedCompetencyDataRepository.Object);

            candidateObject = new CandidateDomainObject()
            {
                FirstName         = "test",
                LastName          = "user",
                Id                = 1,
                EmailAddress      = "*****@*****.**",
                HireCandidate     = true,
                InterviewComplete = true,
                ResumeAddress     = new Uri("http://resume.com/tuser")
            };

            manyCandidates = new List <CandidateDomainObject>()
            {
                new CandidateDomainObject()
                {
                    Id = 99
                },
                new CandidateDomainObject()
                {
                    Id = 101
                }
            };

            emptyCandidate = new List <CandidateDomainObject>();

            nullCandidates = null;
        }
예제 #3
0
        public void Post()
        {
            // Arrange
            CandidateController controller = SetUpController();

            // count before
            IEnumerable <Candidate> list1 = controller.Get();
            int countBefore = list1.Count();

            // Act
            Candidate candidate = new Candidate()
            {
                name = "Some Guy", developer = true, qa = true
            };
            var response = controller.Post(candidate);

            // Assert Location
            // For this mock DB, 10 will be the next generated 01
            Assert.AreEqual(String.Format("http://localhost{0}/softclouds/candidate/10", sPortConfig), response.Headers.Location.AbsoluteUri);

            // Response status s/b 201 created
            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);

            /// It might be wiser to have a return count method and test that
            list1 = controller.Get();
            int countAfter = list1.Count();

            Assert.AreEqual(countAfter, countBefore + 1);
        }
 public void TearDown()
 {
     System.Diagnostics.Debug.WriteLine("candidates teardown");
     controller = null;
     context.Database.Delete();
     context = null;
 }
예제 #5
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            _prevMousePos = Input.mousePosition;

            if (Camera.main != null)
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                _raycastHits = Physics.RaycastAll(ray);
            }
        }
        if (Input.GetMouseButton(0))
        {
            Vector3 mousePos   = Input.mousePosition;
            Vector3 mouseDelta = mousePos - _prevMousePos;
            _prevMousePos = mousePos;

            float   mouseHorizontalVelocity = mouseDelta.x * Time.deltaTime * AppConsts.SCREEN_HORIZONTAL_SCROLL_SENSITIVITY;
            Vector3 playerEulerAngles       = MapGenerator.player.rotation.eulerAngles;
            playerEulerAngles.y         += mouseHorizontalVelocity;
            MapGenerator.player.rotation = Quaternion.Euler(playerEulerAngles);
        }
        if (Input.GetMouseButtonUp(0))
        {
            _prevMousePos = Input.mousePosition;

            if (Camera.main != null)
            {
                Ray          ray     = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit[] newHits = Physics.RaycastAll(ray);

                // If something was hit on the way down and up
                if (_raycastHits.Length > 0 && newHits.Length > 0)
                {
                    HashSet <Transform> previousHits = new HashSet <Transform>();
                    for (int i = 0; i < _raycastHits.Length; i++)
                    {
                        previousHits.Add(_raycastHits[i].transform);
                    }
                    for (int i = 0; i < newHits.Length; i++)
                    {
                        if (previousHits.Contains(newHits[i].transform))
                        {
                            // We have a match! View the node!
                            CandidateController candidateController = newHits[i].transform.parent.GetComponent <CandidateController>();
                            if (candidateController != null)
                            {
                                PopupController.showCandidate(candidateController.getCandidateData());
                                Debug.Log(candidateController.getCandidateData().placeName);
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
예제 #6
0
        private CandidateController CandidateController(GeekHunterContext context)
        {
            Seed(context);
            var candidateRepository = new CandidateRepository(context);
            var candidateService    = new CandidateService(candidateRepository);
            var controller          = new CandidateController(candidateService);

            return(controller);
        }
        public CandidateView(CandidateController controller)
        {
            InitializeComponent();
            this.controller = controller;
            this.controller.addObserver(this);

            //initialize list box
            updateDataModel(controller.getAll());
        }
        public void DeleteSuccessfuly()
        {
            bool calledDeleteCandidate = false;
            var  mockRep = new Mock <ICandidateServices>();

            mockRep.Setup(x => x.DeleteCandidate(1)).Callback(() => calledDeleteCandidate = true);
            CandidateController candidateController = new CandidateController(mockRep.Object);;

            candidateController.Delete(1);
            Assert.IsTrue(calledDeleteCandidate);
        }
        public void PutSuccessfuly()
        {
            bool calledInsert = false;
            var  mockRep      = new Mock <ICandidateServices>();

            mockRep.Setup(x => x.Insert(candidateDetailViewModel)).Callback(() => calledInsert = true);
            CandidateController candidateController = new CandidateController(mockRep.Object);;

            candidateController.Put(candidateDetailViewModel);
            Assert.IsTrue(calledInsert);
        }
예제 #10
0
        public void GetById()
        {
            // Arrange
            CandidateController controller = SetUpController();

            // Act
            Candidate result = controller.Get(5);

            // Assert
            Assert.AreEqual(result.name, "Guy 5");
        }
예제 #11
0
        public void DeleteNonExisting()
        {
            // Arrange
            CandidateController controller = SetUpController();

            // 888 does not exist
            var response = controller.Delete(888);

            // Response status Not Found
            Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound);
        }
        public CandidateControllerShould()
        {
            MockCandidateTestResultProcessor = new Mock <ICandidateTestResultProcessor>();
            MockCandidateTestResultProcessor.Setup(x => x.ValidateTestResultsToTestResultLimits(It.IsAny <List <TaskResultLimit> >(), It.IsAny <TaskResultViewModel>())).Returns(value: null);

            _context = InMemoryApplicationDbContext.GetInMemoryApplicationDbContext();
            _sut     = new CandidateController(_context, MockCandidateTestResultProcessor.Object);

            var mockTempData = new Mock <ITempDataDictionary>();

            _sut.TempData = mockTempData.Object;
        }
        public void GetBySkillSuccessfuly()
        {
            bool calledGetBySkill = false;
            var  mockRep          = new Mock <ICandidateServices>();

            mockRep.Setup(x => x.GetBySkill(1)).Callback(() => calledGetBySkill = true);
            CandidateController candidateController = new CandidateController(mockRep.Object);;

            var vm = candidateController.GetBySkill(1);

            Assert.IsTrue(calledGetBySkill);
        }
예제 #14
0
        public void GetWithIdWrongIdTest()
        {
            //Arrange
            Mock <ICandidateRepository> mockCandidateRepository = new Mock <ICandidateRepository>();
            CandidateController         controller = new CandidateController(mockCandidateRepository.Object);

            //Act
            IHttpActionResult actionResult = controller.Get(100);

            //Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
예제 #15
0
    private IEnumerator Start()
    {
        while (!_locationController.isInitialized)
        {
            yield return(null);
        }

        CategoryType[] categoryTypes = getSavedCategoryTypes().ToArray();
        for (int i = 0; i < categoryTypes.Length; i++)
        {
            List <string> categories   = new List <string>();
            CategoryData  categoryData = CATEGORY_TYPES_TO_SEARCH_CATEGORIES[categoryTypes[i]];
            for (int j = 0; j < categoryData.Filters.Length; j++)
            {
                categories.Add(categoryData.Filters[j]);
            }

            string[] outFields =
            {
                "PlaceName",
                "Place_Addr",
                "City",
                "Region",
                "Location",
            };
            float longitude  = _locationController.getLongitude();
            float latitude   = _locationController.getLatitude();
            int   maxResults = AppConsts.DEFAULT_MAX_RESULTS;
            List <CandidateData> candidateData = ArcGSIRequestHelper.findAddressCandidates(categories.ToArray(), outFields, longitude, latitude, maxResults);

            Material candidateMaterial = GameObject.Instantiate(_candidatePrefab.meshRenderer.sharedMaterial);
            candidateMaterial.color = categoryData.Color;

            for (int j = 0; j < candidateData.Count; j++)
            {
                // Skip earth since yes, that's a data point
                if (candidateData[j].placeName.Equals("Earth"))
                {
                    continue;
                }

                CandidateController candidateInstance = GameObject.Instantiate(_candidatePrefab);
                candidateInstance.Initialize(candidateData[j]);
                candidateInstance.transform.position = new Vector3((candidateData[j].x - longitude) * AppConsts.MAP_SCALE_FACTOR, 0, (candidateData[j].z - latitude) * AppConsts.MAP_SCALE_FACTOR);

                candidateInstance.meshRenderer.sharedMaterial = candidateMaterial;

                _activeCandidates.Add(candidateInstance);
            }
        }
    }
예제 #16
0
        public async Task ShouldCreateACandidateAsync()
        {
            var controller = new CandidateController();

            var candidate = new CandidateBuilder().DataBuilder().Build();

            var result = await controller.PostCandidate(candidate);

            var candidateCreated = await Context.Candidates.FindAsync(result);

            Assert.IsNotNull(candidateCreated);

            Assert.AreEqual("Nome Teste", candidateCreated.Name);
        }
예제 #17
0
        public void Get()
        {
            // Arrange
            CandidateController controller = SetUpController();

            // Act
            IEnumerable <Candidate> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count(), 9);
            // assuming no sorting
            Assert.AreEqual(result.ElementAt(0).name, "Guy 1");
        }
예제 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            var id       = e.ExtraParams["Id"];
            var recordId = e.ExtraParams["RecordId"];

            if (int.TryParse(id, out var resultId) && resultId > 0)
            {
                CandidateController.Delete(resultId);
                if (int.TryParse(recordId, out var resultRecordId) && resultRecordId > 0)
                {
                    RecordController.Delete(resultRecordId);
                }
            }
            gpCandidate.Reload();
        }
예제 #19
0
        public void Should_Be_Ok_When_Find_By_Id(int userId, int accelerationId, int companyId)
        {
            var fakes       = new Fakes();
            var fakeService = fakes.FakeCandidateService().Object;
            var expected    = fakes.Mapper.Map <CandidateDTO>(fakeService.FindById(userId, accelerationId, companyId));

            var controller = new CandidateController(fakeService, fakes.Mapper);
            var result     = controller.Get(userId, accelerationId, companyId);

            Assert.IsType <OkObjectResult>(result.Result);
            var actual = (result.Result as OkObjectResult).Value as CandidateDTO;

            Assert.NotNull(actual);
            Assert.Equal(expected, actual, new CandidateDTOIdComparer());
        }
예제 #20
0
        public void Should_Be_Ok_When_Find_By_Accelaration_Id(int accelerationId)
        {
            var fakes       = new Fakes();
            var fakeService = fakes.FakeCandidateService().Object;
            var expected    = fakeService.FindByAccelerationId(accelerationId).
                              Select(x => fakes.Mapper.Map <CandidateDTO>(x)).
                              ToList();

            var controller = new CandidateController(fakeService, fakes.Mapper);
            var result     = controller.GetAll(accelerationId: accelerationId);

            Assert.IsType <OkObjectResult>(result.Result);
            var actual = (result.Result as OkObjectResult).Value as List <CandidateDTO>;

            Assert.NotNull(actual);
            Assert.Equal(expected, actual, new CandidateDTOIdComparer());
        }
예제 #21
0
        /*
         * Constructor
         */
        public OptionView(OptionController optionController, CandidateController candidateController,
                          DepartmentController departmentController)
        {
            InitializeComponent();

            this.optionController     = optionController;
            this.departmentController = departmentController;
            this.candidateController  = candidateController;

            comboBoxCandidate.DropDownStyle  = ComboBoxStyle.DropDownList;
            comboBoxDepartment.DropDownStyle = ComboBoxStyle.DropDownList;

            optionController.addObserver(this);
            candidateController.addObserver(this);
            departmentController.addObserver(this);
            update();
        }
예제 #22
0
        public void ProcessRequest(HttpContext context)
        {
            _start = Start;
            _limit = Limit;

            context.Response.ContentType = "text/plain";

            // start
            if (!string.IsNullOrEmpty(context.Request["start"]))
            {
                _start = int.Parse(context.Request["start"]);
            }

            // limit
            if (!string.IsNullOrEmpty(context.Request["limit"]))
            {
                _limit = int.Parse(context.Request["limit"]);
            }

            if (!string.IsNullOrEmpty(context.Request["keyword"]))
            {
                _keyword = context.Request["keyword"];
            }

            if (DateTime.TryParseExact(context.Request["fromDate"], "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parseFromDate))
            {
                _fromDate = parseFromDate;
            }
            if (DateTime.TryParseExact(context.Request["toDate"], "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parseToDate))
            {
                _toDate = parseToDate;
            }

            CandidateType?type = null;

            if (!string.IsNullOrEmpty(context.Request["candidateType"]))
            {
                type = (CandidateType)Enum.Parse(typeof(CandidateType), context.Request["candidateType"]);
            }

            var pageResult =
                CandidateController.GetPaging(_keyword, null, null, type, _fromDate, _toDate, false, null, _start, _limit);

            context.Response.ContentType = "text/json";
            context.Response.Write("{{TotalRecords:{0},Data:{1}}}".FormatWith(pageResult.Total, Ext.Net.JSON.Serialize(pageResult.Data)));
        }
예제 #23
0
        public void PostMethodInternalServerError()
        {
            //Arrange
            Candidate updateCandidate = new Candidate
            {
                CandidateId = "123",
                FirstName   = "bob"
            };

            Mock <ICandidateRepository> mockCandidateRepository = new Mock <ICandidateRepository>();

            mockCandidateRepository.Setup(x => x.InsertCandidateToDatabase(updateCandidate)).Returns(false);
            CandidateController controller = new CandidateController(mockCandidateRepository.Object);

            //Act
            IHttpActionResult response = controller.Post(updateCandidate);

            Assert.IsInstanceOfType(response, typeof(InternalServerErrorResult));
        }
예제 #24
0
        public void Delete()
        {
            // Arrange
            CandidateController controller = SetUpController();

            // count before
            IEnumerable <Candidate> list1 = controller.Get();
            int countBefore = list1.Count();
            var response    = controller.Delete(5);

            /// It might be wiser to have a return count method and test that
            list1 = controller.Get();
            int countAfter = list1.Count();

            Assert.AreEqual(countAfter, countBefore - 1);

            // Response status s/b 200 OK
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
        }
        static void Main()
        {
            CandidateValidator      validatorCandidate  = new CandidateValidator();
            CandidateFileRepository repositoryCandidate = new CandidateFileRepository(validatorCandidate, "../../Data/Candidates.txt");
            CandidateController     controllerCandidate = new CandidateController(repositoryCandidate);

            DepartmentValidator      validatorDepartment  = new DepartmentValidator();
            DepartmentFileRepository repositoryDepartment = new DepartmentFileRepository(validatorDepartment, "../../Data/Departments.txt");
            DepartmentController     controllerDepartment = new DepartmentController(repositoryDepartment);

            OptionValidator      validatorOption  = new OptionValidator();
            OptionFileRepository repositoryOption = new OptionFileRepository(validatorOption, "../../Data/Options.txt",
                                                                             repositoryDepartment, repositoryCandidate);
            OptionController controllerOption = new OptionController(repositoryOption);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new HomePage(
                                new CandidateView(controllerCandidate),
                                new DepartmentView(controllerDepartment),
                                new OptionView(controllerOption, controllerCandidate, controllerDepartment)));
        }
예제 #26
0
        public void PutReturnsContentResult()
        {
            // Arrange
            Candidate candidate = new Candidate
            {
                CandidateId = "123",
                FirstName   = "bob"
            };

            var mockRepository = new Mock <ICandidateRepository>();
            var controller     = new CandidateController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.Put(candidate);
            var contentResult = actionResult as NegotiatedContentResult <Candidate>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual("123", contentResult.Content.CandidateId);
        }
예제 #27
0
        public void Put()
        {
            // Arrange
            CandidateController controller      = SetUpController();
            Candidate           candidateBefore = controller.Get(7);

            // Act
            candidateBefore.name = "Some Guy";
            var response = controller.Put(7, candidateBefore);


            Candidate candidateAfter = controller.Get(7);

            // Response status s/b 200 OK
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);

            // Name was changed
            Assert.AreEqual(candidateAfter.name, "Some Guy");

            // No change
            Assert.AreEqual(candidateAfter.phone, candidateBefore.phone);
        }
예제 #28
0
        public void GetWithIdTest()
        {
            //Arrange
            Mock <ICandidateRepository> mockCandidateRepository = new Mock <ICandidateRepository>();

            mockCandidateRepository.Setup(x => x.GetCandidateById(12)).Returns(new Candidate
            {
                CandidateId = "12",
                FirstName   = "bob"
            });
            CandidateController controller = new CandidateController(mockCandidateRepository.Object);

            //Act
            IHttpActionResult actionResult = controller.Get(12);
            var contentResult = actionResult as OkNegotiatedContentResult <Candidate>;

            //Assert
            mockCandidateRepository.Verify(x => x.GetCandidateById(12), Times.Exactly(1));
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsNotNull(contentResult.Content.FirstName);
            Assert.AreEqual(contentResult.Content.CandidateId, "12");
        }
예제 #29
0
        public void PostTest()
        {
            //Arrange
            Candidate updateCandidate = new Candidate
            {
                CandidateId = "123",
                FirstName   = "bob"
            };

            Mock <ICandidateRepository> mockCandidateRepository = new Mock <ICandidateRepository>();

            mockCandidateRepository.Setup(x => x.InsertCandidateToDatabase(updateCandidate)).Returns(true);

            CandidateController controller = new CandidateController(mockCandidateRepository.Object);

            //Act
            IHttpActionResult response = controller.Post(updateCandidate);
            var contentResult          = response as CreatedAtRouteNegotiatedContentResult <Candidate>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual("DefaultApi", contentResult.RouteName);
            Assert.AreEqual("123", contentResult.RouteValues["id"]);
        }
예제 #30
0
        private CandidateController SetUpController()
        {
            // Arrange
            CandidateController controller = new CandidateController(new CandidateDbCtx());

            // Setup Request
            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri(String.Format("http://localhost{0}/candidate", sPortConfig))
            };
            controller.Configuration = new HttpConfiguration();
            controller.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            controller.RequestContext.RouteData = new HttpRouteData(
                route: new HttpRoute(),
                values: new HttpRouteValueDictionary {
                { "controller", "candidate" }
            });

            return(controller);
        }