public void Edit_HappyPath()
        {
            AnamnesesController controller;
            AnamneseViewModel   formModel;

            try
            {
                // obtains a valid patient
                Firestarter.CreateFakePatients(this.db.Doctors.First(), this.db, 1);
                this.db.SaveChanges();
                var patientId = this.db.Patients.First().Id;

                formModel = new AnamneseViewModel()
                {
                    PatientId            = patientId,
                    Conclusion           = "This is my anamnese",
                    DiagnosticHypotheses = new List <DiagnosticHypothesisViewModel>()
                    {
                        new DiagnosticHypothesisViewModel()
                        {
                            Text = "Text", Cid10Code = "Q878"
                        },
                        new DiagnosticHypothesisViewModel()
                        {
                            Text = "Text2", Cid10Code = "Q879"
                        }
                    }
                };

                var mr = new MockRepository(true);
                controller = mr.CreateController <AnamnesesController>();
            }
            catch
            {
                Assert.Inconclusive("Test initialization has failed.");
                return;
            }

            // executing the test
            controller.Create(new[] { formModel });

            Assert.IsTrue(controller.ModelState.IsValid);

            var anamneses            = this.db.Anamnese.ToList();
            var diagnosticHypotheses = this.db.DiagnosticHypotheses.ToList();

            Assert.AreEqual(1, anamneses.Count);
            Assert.AreEqual(2, diagnosticHypotheses.Count);
        }
        public void Delete_HappyPath()
        {
            // obtains a valid patient
            Firestarter.CreateFakePatients(this.db.Doctors.First(), this.db);
            this.db.SaveChanges();
            var patientId = this.db.Patients.First().Id;

            var formModel = new AnamneseViewModel()
            {
                PatientId            = patientId,
                Conclusion           = "This is my anamnese",
                DiagnosticHypotheses = new List <DiagnosticHypothesisViewModel>()
                {
                    new DiagnosticHypothesisViewModel()
                    {
                        Text = "Text", Cid10Code = "Q878"
                    },
                    new DiagnosticHypothesisViewModel()
                    {
                        Text = "Text2", Cid10Code = "Q879"
                    }
                }
            };

            var mr         = new MockRepository(true);
            var controller = mr.CreateController <AnamnesesController>();

            controller.Create(new[] { formModel });

            Assert.IsTrue(controller.ModelState.IsValid);

            // get's the newly created anamnese
            var newlyCreatedAnamnese = this.db.Anamnese.First();

            // tries to delete the anamnese
            var result = controller.Delete(newlyCreatedAnamnese.Id);
            JsonDeleteMessage deleteMessage = (JsonDeleteMessage)result.Data;

            Assert.AreEqual(true, deleteMessage.success);
            Assert.AreEqual(0, this.db.Anamnese.Count());
        }
Example #3
0
        public ActionResult Edit(int?id, int?patientId, int?y, int?m, int?d)
        {
            AnamneseViewModel viewModel = null;

            if (id != null)
            {
                viewModel = GetViewModel(
                    (from a in this.db.Anamnese where a.Id == id select a).First(),
                    this.GetToLocalDateTimeConverter());
            }
            else
            {
                viewModel = new AnamneseViewModel
                {
                    Id                = null,
                    PatientId         = patientId,
                    MedicalRecordDate = DateTimeHelper.CreateDate(y, m, d) ?? this.GetPracticeLocalNow(),
                };
            }

            return(this.View("Edit", viewModel));
        }