public void CreateTest() { PartialViewResult rv = (PartialViewResult)_controller.Create(); Assert.IsInstanceOfType(rv.Model, typeof(PatientVM)); PatientVM vm = rv.Model as PatientVM; Patient v = new Patient(); v.ID = 92; v.IdNumber = "9hTGN"; v.PhotoId = AddPhoto(); vm.Entity = v; _controller.Create(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <Patient>().FirstOrDefault(); Assert.AreEqual(data.ID, 92); Assert.AreEqual(data.IdNumber, "9hTGN"); Assert.AreEqual(data.CreateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10); } }
public void GET_Create() { //Act var result = (ViewResult)_controller.Create(); //Assert Assert.That(result.ViewName, Is.Empty); }
public void CreateTest() { var response = _controller.Create(); Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(ViewResult)); response = _controller.Create(GetTestPatients().First()); Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(RedirectToActionResult)); _repository.Verify(mock => mock.Add(It.IsAny <Patient>()), Times.Once()); _repository.Verify(mock => mock.Save(), Times.Once()); }
public void GetCreateShouldReturnView() { //Arrange var controller = new PatientController(null, null); // Act var result = controller.Create(); // Assert result.Should().BeOfType <ViewResult>(); }
public void CanCreatePatient() { // Arrange var asyncRequestDispatcherMock = new Mock <IAsyncRequestDispatcher>(); asyncRequestDispatcherMock.Setup(rd => rd.GetAllAsync()).Returns(Task.FromResult(new {})); asyncRequestDispatcherMock.SetupGet(rd => rd.Responses) .Returns(new List <Response> { new GetLookupsByCategoryResponse { Category = "Gender", Lookups = new List <LookupDto> { _genderMale } } }); var requestDisplatcherFactoryMock = new Mock <IRequestDispatcherFactory>(); requestDisplatcherFactoryMock.Setup(r => r.CreateRequestDispatcher()) .Returns(asyncRequestDispatcherMock.Object); var controller = new PatientController(requestDisplatcherFactoryMock.Object, new Mock <IResourcesManager>().Object); ActionResult actionResult = null; var wait = new ManualResetEvent(false); // Act var task = controller.Create(); task.ContinueWith(result => { actionResult = result.Result; wait.Set(); }); wait.WaitOne(); // Assert var partialViewResult = actionResult as PartialViewResult; Assert.IsNotNull(partialViewResult); Assert.IsNotNull(partialViewResult.Model); Assert.AreEqual(typeof(PatientDto), partialViewResult.Model.GetType()); Assert.AreEqual("Create", partialViewResult.ViewName); var lookupDtos = partialViewResult.ViewData["GenderLookupItems"] as List <LookupDto>; Assert.IsNotNull(lookupDtos); Assert.AreEqual("Male", lookupDtos[0].Code); Assert.IsNotNull(partialViewResult.ViewData["Patient"]); }
static void CreatePatient() { for (int i = 1; i < 10; i++) { Patient patient = new Patient(); patient.Address = "patientvej 9" + i; patient.DateOfBirth = new DateTime(2000, i, 10); patient.FirstName = "hamun" + i; patient.Gender = "male"; patient.LastName = "thepatient"; patient.MartialStatus = "single"; patient.PatientNumber = i; patient.Telephone = "+5412056" + i; PatientController pc = new PatientController(); SqlException pcer = pc.Create(patient); } }
static void CreateStaff() { for (int i = 1; i < 10; i++) { Qualification q = new Qualification(); q.DateOfQualification = new DateTime(1995, 10, i); q.NameOfInstitution = "John doe instidution" + i; q.QualificationID = i; q.Type = "Teacher" + i; WorkExperience WE = new WorkExperience(); WE.FinishDate = new DateTime(1999, i, 10); WE.NameOfOrganisation = "John doe organisation" + i; WE.PreviousPosition = "Head of Office" + i; WE.StartDate = new DateTime(1996, i, 10); WE.WorkExperienceID = i; Patient p = new Patient(); p.Address = "John doe vej" + i; p.DateOfBirth = new DateTime(1994, 10, i); p.FirstName = "John" + i; p.Gender = "male"; p.LastName = "dooe" + i; p.MartialStatus = "married"; p.PatientNumber = i; p.Telephone = "+452342311" + i; PatientAppointment pa = new PatientAppointment(); pa.AppointmentNumber = i; pa.AppointmentRoom = "D" + i; pa.DateOfAppointment = new DateTime(1991, i, 10); pa.PatientNumber = i; Staff staff = new Staff(); staff.CurrentPosition = "Chief officer"; staff.AppointmentNumber = i; staff.CurrentSalary = 2.2 + i; staff.DateOfBirth = new DateTime(1999, i, 12); staff.FirstName = "John" + i; staff.FullAddress = "den nye vej 9" + i; staff.Gender = "male"; staff.InsuranceNumber = i; staff.LastName = "Doee" + i; staff.NumberOfHoursPerWeek = i; staff.PermenentOrTemporary = "temp"; staff.QualificationID = i; staff.SalaryPayment = "week"; staff.SalaryScale = "c" + i; staff.StaffNumber = i; staff.WorkExperienceID = i; QualificationController qc = new QualificationController(); WorkExperienceController wec = new WorkExperienceController(); PatientController pc = new PatientController(); PatientAppointmentController pac = new PatientAppointmentController(); StaffController sc = new StaffController(); SqlException qcec = qc.Create(q); SqlException wecec = wec.Create(WE); SqlException pecc = pc.Create(p); SqlException pacec = pac.Create(pa); SqlException errorCode = sc.Create(staff); } }
public void WhenHeClicksOnRegisterButton() { result = controller.Create(patient); }