private void LoadContactList() { ContactUsController contactController = new ContactUsController(); List <ContactUsInfo> objContactList = contactController.ContactUsGetAll(GetPortalID); gdvContacters.DataSource = objContactList; gdvContacters.DataBind(); }
private void DeleteContact(int contactUsID) { ContactUsController contactController = new ContactUsController(); contactController.ContactUsDeleteByID(contactUsID, GetPortalID, GetUsername); ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ContactUs/ModuleLocalText", "ContactUsIsDeletedSuccessfully"), "", SageMessageType.Success); LoadContactList(); }
public void Index_when_saving_feedback_throws_exception_action_index() { //arrange var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); //act var result = (ViewResult)controller.Index(contact); //assert Assert.AreEqual("Index", result.ViewName); //cleanup }
public async Task Post_CheckServiceCalled_ReturnsTrue() { // Arrange var mockContactUsService = new Mock <IContactUsService>(); mockContactUsService.Setup(service => service.AddAsync(It.IsAny <ContactUsModel>())).ReturnsAsync(await Task.FromResult(1)); ContactUsModel contactUsModel = new ContactUsModel(); var controller = new ContactUsController(mockContactUsService.Object); //Act await controller.Post(contactUsModel); mockContactUsService.Verify(x => x.AddAsync(It.IsAny <ContactUsModel>()), Times.Once); }
public async Task CanGetViewWithDefaultModel() { var service = Substitute.For <IContactUsService>(); var controller = new ContactUsController(service); var result = await controller.RenderContactUsTask(); var model = (ContactUsModel)result.Model; Assert.Null(model.Name); Assert.Null(model.Email); Assert.Null(model.Message); }
public void SetUp() { controllerContext = new HttpControllerContext(); HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null)); controllerContext.Request = new HttpRequestMessage(); controllerContext.Request.Headers.Add("Basic", "password"); controller = new ContactUsController(); controller.ControllerContext = controllerContext; }
public async Task Post_ValidModel_ReturnsOkResultAsync(string email, string name, string message) { // Arrange var mockContactUsService = new Mock <IContactUsService>(); mockContactUsService.Setup(service => service.AddAsync(It.IsAny <ContactUsModel>())).ReturnsAsync(await Task.FromResult(1)); ContactUsModel contactUsModel = new ContactUsModel() { Email = email, Name = name, Message = message }; var controller = new ContactUsController(mockContactUsService.Object); //Act var result = await controller.Post(contactUsModel); //Assert Assert.IsType <OkResult>(result); }
public void Index_when_model_state_is_invalid_redirect_to_action_index() { //arrange var mock = new Mock <IContactService>(); _contactService = mock.Object; var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); controller.ModelState.AddModelError("test", "error"); //act var result = (ViewResult)controller.Index(contact); //assert Assert.AreEqual("Index", result.ViewName); //cleanup _contactService = null; }
public void Index_when_model_state_is_valid_redirect_to_action_confirm() { //arrange var mock = new Mock <IContactService>(); _contactService = mock.Object; var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); controller.ModelState.Clear(); //act var result = (RedirectToRouteResult)controller.Index(contact); //assert Assert.AreEqual("Confirm", result.RouteValues["action"]); //cleanup _contactService = null; }
public async Task WillSaveDataWhenModelIsValid() { var service = Substitute.For <IContactUsService>(); var controller = new ContactUsController(service); var model = new ContactUsModel { Name = "Aaron", Email = "*****@*****.**", Message = "Test message" }; var _ = await controller.PostContactUsAsync(model); service .Received() .AddFeedbackAsync(Arg.Is(model.Name), Arg.Is(model.Email), Arg.Is(model.Message)) .IgnoreAwaitForNSubstituteAssertion(); }
public void Before() { _target = new ContactUsController(new CustomerMessageRepo(base.DbContext)); }