public void DeleteAsync_ShouldThrowInvalidInterviewException_WhenInterviewNotExists()
        {
            var interviewService = new InterviewService(this.dbContext);

            Assert.Throws <InvalidInterviewException>(
                () => interviewService.DeleteAsync(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()).GetAwaiter().GetResult());
        }
        public async Task EditAsync_ShouldAddCorrectEditToInterview_WhenInterviewExists()
        {
            var interviewToEditId = Guid.NewGuid().ToString();
            var interview         = new Interview()
            {
                Id = interviewToEditId
            };

            await this.dbContext.Interviews.AddAsync(interview);

            await this.dbContext.SaveChangesAsync();

            var interviewWithEdits = new InterviewEditInputModel {
                Id = interviewToEditId
            };

            var interviewService = new InterviewService(this.dbContext);

            var editorId = Guid.NewGuid().ToString();
            await interviewService.EditAsync(interviewWithEdits, editorId);

            var actualInterview = this.dbContext.Interviews.First();

            Assert.Equal(editorId, actualInterview.Edits.FirstOrDefault()?.EditorId);
        }
Example #3
0
        private void buttonOpenInterview_Click(object sender, EventArgs e)
        {
            try
            {
                Button btn = (Button)sender;
                Guid   id  = Guid.Parse(btn.Tag.ToString());

                Predicate <InterviewService> p = new Predicate <InterviewService>(x => x.CurrentInterview.Id.Equals(id));

                if (this.ProjectSrv.InterviewServices.Any(x => p(x)) == false)
                {
                    throw new KeyNotFoundException("The requested Interview could not be found.");
                }

                InterviewService IS = this.ProjectSrv.InterviewServices.Single(x => p(x));
                this.Hide();
                FormInterview frm = new FormInterview();
                frm.CurrentInterviewService = IS;

                frm.ShowDialog();
                frm = null;
                this.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while Opening an Interview");
            }
            finally
            {
            }
        }
        public async Task GetAsync_Projection_ShouldGetCorrectInterview_WhenInterviewExists()
        {
            await this.dbContext.Interviews.AddRangeAsync(new List <Interview>()
            {
                new Interview {
                    Id = "1"
                },
                new Interview {
                    Id = "2"
                },
                new Interview {
                    Id = "3"
                },
            });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);

            var wantedInterviewId   = "2";
            var expectedInterviewId = wantedInterviewId;
            var interview           = await interviewService.GetAsync <FakeInterview>(wantedInterviewId);

            Assert.Equal(expectedInterviewId, interview.Id);
        }
Example #5
0
        public ActionResult InterviewEdit(int id, InterviewEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.InterviewID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new InterviewService(userId);

            if (service.UpdateInterview(model))
            {
                TempData["SaveResult"] = "Your Lead was updated.";
                return(RedirectToAction("InterviewIndex"));
            }

            ModelState.AddModelError("", "Your Interview could not be updated.");
            return(View(model));
        }
        public async Task LatestAsync_ShouldReturnsCorrectCountOfInterviews()
        {
            await this.dbContext.Interviews.AddRangeAsync(new List <Interview>
            {
                new Interview {
                    IsDeleted = true
                },
                new Interview {
                    IsDeleted = false
                },
                new Interview {
                    IsDeleted = true
                },
                new Interview {
                    IsDeleted = false
                },
                new Interview {
                    IsDeleted = false
                },
            });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);

            var givenCount = 2;
            var result     = await interviewService.LatestAsync <FakeInterview>(givenCount);

            var expectedCount = givenCount;
            var actualCount   = result.Count();

            Assert.Equal(expectedCount, actualCount);
        }
        public async Task LatestAsync_ShouldReturnsLatest()
        {
            await this.dbContext.Interviews.AddRangeAsync(new List <Interview>
            {
                new Interview {
                    Id = "1", PublishedOn = DateTime.UtcNow.AddHours(-2)
                },
                new Interview {
                    Id = "2", PublishedOn = DateTime.UtcNow
                },
                new Interview {
                    Id = "3", PublishedOn = DateTime.UtcNow.AddHours(-20)
                },
                new Interview {
                    Id = "4", PublishedOn = DateTime.UtcNow.AddHours(-12)
                },
                new Interview {
                    Id = "5", PublishedOn = DateTime.UtcNow.AddHours(-8)
                },
            });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);
            var result           = await interviewService.LatestAsync <FakeInterview>(3);

            var expectedIds = new List <string> {
                "2", "1", "5"
            };

            Assert.True(result.All(a => expectedIds.Contains(a.Id)));
        }
Example #8
0
        public ActionResult Delete(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new InterviewService(userId);
            var model   = service.GetInterviewById(id);

            return(View(model));
        }
Example #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            IInterviewService intService = new InterviewService();
            Interview         interview  = intService.GetById(id);

            intService.Delete(interview);
            intService.Commit();
            return(RedirectToAction("Index"));
        }
Example #10
0
        public void AddInterview(Interview i)
        {
            this.CurrentProject.Interviews.Add(i);
            InterviewService IS = new InterviewService(this, i);

            IS.defineDefaultScale();
            this.InterviewServices.Add(IS);
            this.FirePropertyChanged("CurrentProject");
        }
        public void EditAsync_ShouldThrowInvalidInterviewException_WhenInterviewNotExists()
        {
            var interviewWithEdits = new InterviewEditInputModel {
                Id = Guid.NewGuid().ToString()
            };

            var interviewService = new InterviewService(this.dbContext);

            Assert.Throws <InvalidInterviewException>(
                () => interviewService.EditAsync(interviewWithEdits, Guid.NewGuid().ToString()).GetAwaiter().GetResult());
        }
        public async Task CreateAsync_ShouldAddCorrectCreatorToNewInterview()
        {
            var interviewService = new InterviewService(this.dbContext);

            var creatorId = Guid.NewGuid().ToString();
            await interviewService.CreateAsync(new InterviewCreateInputModel(), creatorId);

            var interviewFromDb = this.dbContext.Interviews.FirstOrDefault();

            Assert.Equal(creatorId, interviewFromDb?.CreatorId);
        }
        public void InitializeTest()
        {
            Stubs.Initialize();
            Stubs.InterviewRepository.Add(new Interview());
            Stubs.InterviewRepository.Add(new Interview());
            Stubs.InterviewRepository.Add(new Interview());
            Stubs.InterviewRepository.Add(new Interview());
            Stubs.UnitOfWork.Commit();

            m_target = new InterviewService();
        }
Example #14
0
        public ActionResult InterviewDelete(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new InterviewService(userId);

            service.DeleteInterview(id);

            TempData["SaveResult"] = "Your Interview was deleted";

            return(RedirectToAction("InterviewIndex"));
        }
Example #15
0
        private static async Task Execute()
        {
            var service = new InterviewService(HttpClientFactory.Create());
            var stocks  = await service.GetStocksAsync();

            foreach (var stock in stocks)
            {
                System.Console.WriteLine($"{stock.Symbol}: {stock.Price}");
            }

            return;
        }
        public async Task CreateAsync_ShouldAddNewInterviewToDb()
        {
            var interviewService = new InterviewService(this.dbContext);

            var creatorId = Guid.NewGuid().ToString();
            await interviewService.CreateAsync(new InterviewCreateInputModel(), creatorId);

            const int expected = 1;
            var       actual   = this.dbContext.Interviews.Count();

            Assert.Equal(expected, actual);
        }
        public async Task DeleteAsync_ShouldThrowInvalidInterviewException_WhenIdExistsButInterviewIsSoftDeleted()
        {
            var interviewToDeleteId = Guid.NewGuid().ToString();

            await this.dbContext.Interviews.AddAsync(new Interview { Id = interviewToDeleteId, IsDeleted = true });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);

            Assert.Throws <InvalidInterviewException>(
                () => interviewService.DeleteAsync(interviewToDeleteId, Guid.NewGuid().ToString()).GetAwaiter().GetResult());
        }
Example #18
0
        public ActionResult InterviewCreate(InterviewCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new InterviewService(userId);

            service.CreateInterview(model);

            return(RedirectToAction("InterviewIndex"));
        }
        public async Task DeleteAsync_ShouldSoftDeleteInterview_WhenInterviewExists()
        {
            var interviewId = Guid.NewGuid().ToString();

            await this.dbContext.Interviews.AddAsync(new Interview { Id = interviewId, IsDeleted = false });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);
            var editorId         = Guid.NewGuid().ToString();
            await interviewService.DeleteAsync(interviewId, editorId);

            var resultInterview = await this.dbContext.Interviews.FindAsync(interviewId);

            Assert.True(resultInterview.IsDeleted);
        }
Example #20
0
        // GET: Interview/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IInterviewService intService = new InterviewService();
            Interview         interview  = intService.GetById(id);

            //intService.Update(interview);
            if (interview == null)
            {
                return(HttpNotFound());
            }
            return(View(interview));
        }
        public async Task DeleteAsync_ShouldAddCorrectEditToInterview_WhenInterviewExists()
        {
            var interviewId = Guid.NewGuid().ToString();

            await this.dbContext.Interviews.AddAsync(new Interview { Id = interviewId, IsDeleted = false });

            await this.dbContext.SaveChangesAsync();

            var interviewService = new InterviewService(this.dbContext);
            var editorId         = Guid.NewGuid().ToString();
            await interviewService.DeleteAsync(interviewId, editorId);

            var resultInterview = await this.dbContext.Interviews.FindAsync(interviewId);

            Assert.Equal(editorId, resultInterview.Edits.FirstOrDefault()?.EditorId);
        }
Example #22
0
        // GET: Interview/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IInterviewService intService = new InterviewService();
            Interview         interview  = intService.GetById(id);

            //Bloc bloc = db.Blocs.Find(id);
            if (interview == null)
            {
                return(HttpNotFound());
            }
            return(View(interview));
        }
        public async Task EditAsync_ShouldSaveChangesToDb_WhenInterviewExists()
        {
            var interviewToEditId = Guid.NewGuid().ToString();
            var interview         = new Interview
            {
                Id          = interviewToEditId,
                Title       = "CurrentTitle",
                Interviewed = "CurrentInterviewed",
                Author      = "CurrentAuthor",
                Content     = "CurrentContent",
                Image       = new Image {
                    Id = "1"
                },
            };

            await this.dbContext.Interviews.AddAsync(interview);

            await this.dbContext.SaveChangesAsync();

            var interviewWithEdits = new InterviewEditInputModel()
            {
                Id          = interviewToEditId,
                Title       = "NewTitle",
                Interviewed = "NewInterviewed",
                Author      = "NewAuthor",
                Content     = "NewContent",
                Image       = new ImageBaseInputModel {
                    Id = "2"
                },
            };

            var interviewService = new InterviewService(this.dbContext);

            var editorId = Guid.NewGuid().ToString();
            await interviewService.EditAsync(interviewWithEdits, editorId);

            var actualInterview = this.dbContext.Interviews.First();

            Assert.Equal(interviewWithEdits.Id, actualInterview.Id);
            Assert.Equal(interviewWithEdits.Title, actualInterview.Title);
            Assert.Equal(interviewWithEdits.Interviewed, actualInterview.Interviewed);
            Assert.Equal(interviewWithEdits.Author, actualInterview.Author);
            Assert.Equal(interviewWithEdits.Content, actualInterview.Content);
            Assert.Equal(interviewWithEdits.Content, actualInterview.Content);
            Assert.Equal(interviewWithEdits.Image.Id, actualInterview.ImageId);
        }
Example #24
0
        public void TestClustering()
        {
            ProjectService ps = new ProjectService(R);

            ps.AddInterview((new Interview(ps.CurrentProject)));
            InterviewService IS = ps.InterviewServices.Last();

            IS.CurrentInterview.GridName = "bell2010";
            IS.GetFromR(true);
            IS.R.Evaluate(IS.CurrentInterview.GridName);

            Dictionary <String, object> d = new Dictionary <string, object>();

            d.Add("along", 1);
            d.Add("print", false);
            IS.cluster(d);

            IS.R.Evaluate(IS.CurrentInterview.GridName);
        }
Example #25
0
        public ActionResult Create(Interview interview)
        {
            try
            {
                // TODO: Add insert logic here
                //Ajouter un interview à partir de la classe InterviewService


                IInterviewService intService = new InterviewService();
                intService.Add(interview);
                intService.Commit();
                //intService.Dispose();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(interview));
            }
        }
Example #26
0
        public ActionResult InterviewEdit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new InterviewService(userId);
            var detail  = service.GetInterviewById(id);
            var model   =
                new InterviewEdit
            {
                InterviewID          = detail.InterviewID,
                LeadID               = detail.LeadID,
                PrimaryInterviewer   = detail.PrimaryInterviewer,
                SecondaryInterviewer = detail.SecondaryInterviewer,
                InterviewTimeDateUtc = detail.InterviewTimeDateUtc,
                InterviewerLink      = detail.InterviewerLink,
                Notes = detail.Notes
            };

            return(View(model));
        }
Example #27
0
        private void addGridFromR(string GridName, string cmd)
        {
            if (cmd.Length > 0)
            {
                this.R.Evaluate(cmd);
            }

            Interview i = new Interview(this.CurrentProject);

            i.GridName = GridName;

            InterviewService iService = new InterviewService(this, i);

            iService.Reset();
            iService.GetFromR(true);
            this.AddInterview(iService.CurrentInterview);

            this.CurrentProject.FirePropertyChanged("Interviews");
            this.FirePropertyChanged("CurrentProject");
        }
Example #28
0
        private void toolStripMenuItemStatsElementsConstructs_Click(object sender, EventArgs e)
        {
            try
            {
                dlgValues dlg = new dlgValues();
                dlg.Text           = "Please provide custom parameters for the statsConstructs function";
                dlg.AcceptedValues = InterviewService.StatsGridAcceptedValues();
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    throw new Exception("Aborted by User");
                }

                RDotNet.DataFrame df = this.interviewService.StatsGrid(false, dlg.OptionalValues);
                RHelper.RHelper.FillDataGridViewFromR(df, getDGV(getNewTabpage("statsConstructs")), 3);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while Calculating statistics for Constructs");
            }
        }
Example #29
0
 private void bertinClusterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         dlgValues dlg = new dlgValues();
         dlg.Text           = "Please provide custom parameters for the BertinCluster function";
         dlg.AcceptedValues = InterviewService.BertinClusterAcceptedValues();
         if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
         {
             throw new Exception("Aborted by User");
         }
         this.interviewService.BertinCluster(dlg.OptionalValues);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
         MessageBox.Show(ex.Message, "Error while Bertin-Clustering");
     }
 }
Example #30
0
 private void principalComponentAnalysisPCAToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         dlgValues dlg = new dlgValues();
         dlg.Text           = "Please provide custom parameters for the constructPca function";
         dlg.AcceptedValues = InterviewService.PCAAcceptedValues();
         if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
         {
             throw new Exception("Aborted by User");
         }
         this.interviewService.ConstructPCA(dlg.OptionalValues);
         MessageBox.Show("Please Check the R-Output in the Console for the results!", "Principal component analysis (PCA) of inter-construct correlations");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
         MessageBox.Show(ex.Message, "Error during the Principal component analysis (PCA)");
     }
 }