public void ForMessage_builder_method() { var continuation = AjaxContinuation.ForMessage("some message"); continuation.Success.ShouldBeFalse(); continuation.Message.ShouldEqual("some message"); }
public AjaxContinuation Post(ChangePasswordModel model) { var user = _userService.GetUserByLogin(model.UserName); var notification = new Notification(); if (user == null) { notification.RegisterMessage(StringToken.FromKeyString("User Name", "User name does not exist!")); } else { try { user.ChangePassword(_passwordService, model.OldPassword, model.Password); } catch (Exception ex) { notification.RegisterMessage(StringToken.FromKeyString("Password", ex.Message)); } } return (notification.IsValid() ? AjaxContinuation.ForNavigateWholePage("/account/logoff") : AjaxContinuation.ForError(notification)); }
public AjaxContinuation get_dependencies_type(AssetDependenciesRequest request) { var logs = _assetLogs.Entries .Select(l => l.Name); IEnumerable <IGrouping <string, string> > fileNames = logs.GroupBy(x => new FileInfo(x).Extension); var javascripts = fileNames.Where(g => g.Key == ".js"); object data = null; foreach (var javascript in javascripts) { var dependencies = javascript.Select(x => _graph.FileDependencyFor(x)); data = dependencies.Select(d => new { d, fromName = d.Name }).SelectMany(@t => @t.d.Dependencies(), (@t, sub) => new { source = @t.fromName, target = sub.Name, type = "suit" }); } var datum = AjaxContinuation.Successful(); datum["datum"] = data; return(datum); }
private FormRequest requestFor <T>() where T : class, new() { var services = new InMemoryServiceLocator(); services.Add <IChainResolver>(new ChainResolutionCache(theGraph)); services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest())); theRequest = new InMemoryFubuRequest(); theNotification = Notification.Valid(); theRequest.Set(theNotification); services.Add(theRequest); var request = new FormRequest(new ChainSearch { Type = typeof(T) }, new T()); request.Attach(services); request.ReplaceTag(new FormTag("test")); theContinuation = AjaxContinuation.Successful(); theContinuation.ShouldRefresh = true; var resolver = MockRepository.GenerateStub <IAjaxContinuationResolver>(); resolver.Stub(x => x.Resolve(theNotification)).Return(theContinuation); services.Add(resolver); return(request); }
public void Successful_builder_method() { var success = AjaxContinuation.Successful(); success.Errors.Any().ShouldBeFalse(); success.Success.ShouldBeTrue(); }
public AjaxContinuation post_ajax(AjaxModel user) { var continuation = AjaxContinuation.Successful(); continuation.Message = "User created: " + user.Name; return(continuation); }
public void ForMessage_via_StringToken() { var token = new SomeMessage(); var continuation = AjaxContinuation.ForMessage(token); continuation.Success.ShouldBeFalse(); continuation.Message.ShouldEqual(token.ToString()); }
public AjaxContinuation post_products_create(Product product) { _repository.Update(product); var continuation = AjaxContinuation.Successful(); continuation.ShouldRefresh = true; return(continuation); }
public AjaxContinuation post_ajax(AjaxIn input) { var continuation = AjaxContinuation.Successful(); continuation.Message = input.Message; return(continuation); }
public static string ValidationOrigin(this AjaxContinuation continuation) { if (continuation.HasData(OriginKey)) { return(continuation[OriginKey].ToString()); } return(Validation.ValidationOrigin.Server); }
public void ForMessage_via_StringToken() { var token = StringToken.FromKeyString("key", "some message"); var continuation = AjaxContinuation.ForMessage(token); continuation.Success.ShouldBeFalse(); continuation.Message.ShouldEqual(token.ToString()); }
public AjaxContinuation BuildAjaxContinuation() { var url = _urls.UrlFor(new LoginRequest(), "GET"); var continuation = new AjaxContinuation { Success = false, NavigatePage = url }; return(continuation); }
public static AjaxContinuation ForNavigateWholePage(string url) { var forNavigateWholePage = new AjaxContinuation { Success = true }; forNavigateWholePage[NavigatePage] = url; return forNavigateWholePage; }
public static AjaxContinuation ForError(Notification notification) { var ajaxContinuation = new AjaxContinuation { Success = notification.IsValid() }; ajaxContinuation.AddErrors(notification.ToValidationErrors()); return ajaxContinuation; }
public void gets_and_sets_the_validation_origin() { var continuation = new AjaxContinuation(); continuation.ValidationOrigin(ValidationOrigin.Server); continuation.ValidationOrigin().ShouldBe(ValidationOrigin.Server); continuation.ValidationOrigin(ValidationOrigin.Client); continuation.ValidationOrigin().ShouldBe(ValidationOrigin.Client); }
public AjaxContinuation Command(AddProductModel model) { var product = _mapper.Map <AddProductModel, Product>(model); _service.Save(product); var result = AjaxContinuation.Successful(); result["id"] = product.Id; return(result); }
protected override void beforeEach() { theInput = new SampleInputModel(); theNotification = new Notification(); theAjaxContinuation = new AjaxContinuation(); ClassUnderTest.InsideBehavior = MockFor <IActionBehavior>(); MockFor <IFubuRequest>().Stub(x => x.Get <SampleInputModel>()).Return(theInput); MockFor <IValidationFilter <SampleInputModel> >().Stub(x => x.Validate(theInput)).Return(theNotification); MockFor <IAjaxContinuationResolver>().Stub(x => x.Resolve(theNotification)).Return(theAjaxContinuation); }
public FubuContinuation Redirect() { var url = _urls.UrlFor(new LoginRequest(), "GET"); var continuation = new AjaxContinuation { Success = false, NavigatePage = url }; _jsonWriter.Write(continuation.ToDictionary(), MimeType.Json.ToString()); return(FubuContinuation.EndWithStatusCode(HttpStatusCode.Unauthorized)); }
protected override void beforeEach() { theContinuation = MockFor <AjaxContinuation>(); theDictionary = new Dictionary <string, object>(); theContinuation.Stub(x => x.ToDictionary()).Return(theDictionary); MockFor <IFubuRequest>().Stub(x => x.Find <AjaxContinuation>()) .Return(new AjaxContinuation[] { theContinuation }); ClassUnderTest.Invoke(); }
public AjaxContinuation post_project_properties_Name(ProjectViewModel model) { var project = TopicGraph.AllTopics.TryFindProject(model.Name); model.Project.Filename = project.Filename; model.Project.WriteTo(project.Filename); model.Project.Index = project.Index; model.Project.Splash = project.Splash; TopicGraph.AllTopics.AddProject(model.Project); return(AjaxContinuation.Successful()); }
protected override void beforeEach() { theNotification = new Notification(); theAjaxContinuation = new AjaxContinuation(); theSettings = new ValidationSettings(); theSettings.FailAjaxRequestsWith(HttpStatusCode.SeeOther); Services.Inject(theSettings); MockFor <IAjaxContinuationResolver>().Stub(x => x.Resolve(theNotification)).Return(theAjaxContinuation); ClassUnderTest.Handle(theNotification); }
protected override DoNext performInvoke() { var input = _request.Get <CharacterInput>(); if (input.Race == "Ogre" && input.CharacterClass == "Paladin") { var continuation = new AjaxContinuation(); continuation.Errors.Add(new AjaxError { field = "Character", message = "Ogres cannot be Paladins!" }); _request.Set(continuation); return(DoNext.Stop); } return(DoNext.Continue); }
public static AjaxContinuation BuildContinuation(Notification notification) { var continuation = new AjaxContinuation(); continuation.Success = notification.IsValid(); notification .ToValidationErrors() .Each(e => continuation .Errors .Add(new AjaxError { field = e.field, label = e.label, message = e.message })); return(continuation); }
protected override DoNext performInvoke() { try { var message = _request.Get <T>(); _serviceBus.Send(message); _request.Set(AjaxContinuation.Successful()); } catch (Exception e) { _request.Set(new AjaxContinuation { Success = false }); _logger.Error("Error trying to publish message of type " + typeof(T).FullName, e); } return(DoNext.Continue); }
protected override void beforeEach() { var theAccessor = ReflectionHelper.GetAccessor <ValidateFieldTarget>(x => x.Name); theGraph = new RemoteRuleGraph(); theGraph.RegisterRule(theAccessor, new RequiredFieldRule()); Services.Inject(theGraph); theRemoteRule = RemoteFieldRule.For(theAccessor, new RequiredFieldRule()); theInputModel = new ValidateField { Hash = theRemoteRule.ToHash(), Value = "Test" }; theNotification = new Notification(); theContinuation = new AjaxContinuation(); MockFor <IRuleRunner>().Stub(x => x.Run(theRemoteRule, theInputModel.Value)).Return(theNotification); MockFor <IAjaxContinuationResolver>().Stub(x => x.Resolve(theNotification)).Return(theContinuation); }
public AjaxContinuation post_project_ProjectName(TopicToken topic) { if (_lastTimestamp == _reloaded.Timestamp.ToString()) { return(AjaxContinuation.Successful()); } var existing = _tokenCache.TopicStructureFor(topic.ProjectName); var collector = new DeltaCollector(existing, topic); var orderedDeltas = collector.OrderedDeltas().ToArray(); orderedDeltas.Each(x => Debug.WriteLine(x)); collector.ExecuteDeltas(); Task.Factory.StartNew(() => { EventAggregator.SendMessage(new RecycleApplication()); }); _lastTimestamp = _reloaded.Timestamp.ToString(); return(AjaxContinuation.Successful()); }
public AjaxContinuation post_integration(IntegratedJsonBindingTarget target) { _recorder.Record(target); return(AjaxContinuation.Successful()); }
public void Modify(AjaxContinuation continuation, Notification notification) { Continuation = continuation; Notification = notification; }
public AjaxContinuation post_name(NamedEntity entity) { _repository.Update(entity); return(AjaxContinuation.Successful()); }
public static AjaxContinuation ForPage(string url) { var returnValue = new AjaxContinuation(); returnValue[ShowPage] = url; return returnValue; }
public static AjaxContinuation ForDialog(string url) { var returnValue = new AjaxContinuation(); returnValue[ShowDialog] = url; return returnValue; }
public AjaxContinuation get_alternative_for_actionless_view(ActionlessView3 input) { return(AjaxContinuation.Successful()); }
public AjaxContinuation delete_js_method3(Method1Input input) { return(AjaxContinuation.Successful()); }
public AjaxContinuation post_form_Name(FormInput input) { return(AjaxContinuation.Successful()); }