public async Task PostRegisteredOfficeAddress_ModelStateIsInvalid_ReturnsViewModel() { // Arrange IWeeeClient weeeClient = A.Dummy<IWeeeClient>(); ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>(); OrganisationRegistrationController controller = new OrganisationRegistrationController( () => weeeClient, organisationSearcher); var model = new AddressViewModel(); controller.ModelState.AddModelError("Key", "Error"); // To make the model state invalid // Act ActionResult result = await controller.RegisteredOfficeAddress(model); // Assert ViewResult viewResult = result as ViewResult; Assert.NotNull(viewResult); Assert.Equal(model, viewResult.Model); }
public async void PostRegisteredOfficeAddress_PrincipalPlaceOfBusinessIsValid_CallsApiToAddAddressToOrganisation() { // Arrange IWeeeClient weeeClient = A.Fake<IWeeeClient>(); ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>(); OrganisationRegistrationController controller = new OrganisationRegistrationController( () => weeeClient, organisationSearcher); AddressViewModel model = new AddressViewModel(); // Act ActionResult result = await controller.RegisteredOfficeAddress(model); // Assert A.CallTo(() => weeeClient.SendAsync(A<string>._, A<AddAddressToOrganisation>._)) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task PostRegisteredOfficeAddress_PrincipalPlaceOfBusinessIsValid_RedirectsToReviewOrganisationDetails() { // Arrange IWeeeClient weeeClient = A.Fake<IWeeeClient>(); ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>(); OrganisationRegistrationController controller = new OrganisationRegistrationController( () => weeeClient, organisationSearcher); AddressViewModel model = new AddressViewModel(); // Act ActionResult result = await controller.RegisteredOfficeAddress(model); // Assert RedirectToRouteResult redirectToRouteResult = result as RedirectToRouteResult; Assert.NotNull(redirectToRouteResult); Assert.Equal("ReviewOrganisationDetails", redirectToRouteResult.RouteValues["action"]); }
public ActionResult DisplayListOfDoctorsInMap(int id) { ViewBag.idPath = id; List <DoctorViewModel> listofdoctors = new List <DoctorViewModel>(); IDatabaseFactory dbf = new DatabaseFactory(); //user string qr = " SELECT u.`id`,u.`UrlPhoto`,u.`email`,u.`firstName`,u.`lastName`,u.`phoneNumber`,u.`address_id`,u.state from user u,medicalpath m, " + "rdv r WHERE m.id =" + id + " and m.`rendezVous_id`= r.id and u.id = r.users_id"; IEnumerable <PatientForMedicalPathViewModel> dataforpat = dbf.DataContext.Database.SqlQuery <PatientForMedicalPathViewModel>(qr); //address user string addresseForPatient = "select `id`,`fullAddress`,`latitude`,`longit` " + "FROM address u " + "WHERE u.id=" + dataforpat.ElementAt(0).address_id; IEnumerable <AddressViewModel> dataforadd = dbf.DataContext.Database.SqlQuery <AddressViewModel>(addresseForPatient); //patient data PatientForMedicalPathViewModel patient = new PatientForMedicalPathViewModel(); patient = dataforpat.ElementAt(0); patient.address = dataforadd.ElementAt(0); //doctors data string query = "SELECT id,UrlPhoto,email,firstName,lastName,paimentMethode,speciality,address_id,tariff,username " + "FROM user u " + "WHERE u.role=2 AND u.id NOT IN (SELECT doctor_id from pathdoctors p WHERE p.path_id=" + id + ")"; IEnumerable <DoctorViewModel> data = dbf.DataContext.Database.SqlQuery <DoctorViewModel>(query).ToList(); foreach (var i in data) { string addressquery = "select `id`,`fullAddress`,`latitude`,`longit` " + "FROM address u " + "WHERE u.id=" + i.address_id; IEnumerable <AddressViewModel> data2 = dbf.DataContext.Database.SqlQuery <AddressViewModel>(addressquery); foreach (var j in data2) { if (j.id == i.address_id) { AddressViewModel ad = new AddressViewModel(); ad.id = j.id; ad.fullAddress = j.fullAddress; ad.longit = j.longit; ad.latitude = j.latitude; i.address = ad; } } } listofdoctors.AddRange(data); ViewBag.result = listofdoctors; ViewBag.patient = patient; return(View()); }