public async Task SetUp() { ApplicationId = Guid.NewGuid(); SectionId = Guid.NewGuid(); PageId = Guid.NewGuid().ToString(); var dataContext = DataContextHelpers.GetInMemoryDataContext(); dataContext.Applications.Add(new Data.Entities.Application() { Id = ApplicationId, }); dataContext.ApplicationSections.Add(new ApplicationSection() { Id = SectionId, ApplicationId = ApplicationId, QnAData = new QnAData() { Pages = new List <Page> { new Page { PageId = PageId } } } }); dataContext.SaveChanges(); Handler = new GetPageHandler(dataContext); }
public async Task Then_page_complete_is_false() { await Handler.Handle(new ResetPageAnswersRequest(ApplicationId, SectionId, "1"), CancellationToken.None); var getPageResponse = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, "1"), CancellationToken.None); getPageResponse.Value.Complete.Should().BeFalse(); }
public async Task Then_page_answers_are_reset() { await Handler.Handle(new ResetPageAnswersRequest(ApplicationId, SectionId, "1"), CancellationToken.None); var getPageResponse = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, "1"), CancellationToken.None); getPageResponse.Value.PageOfAnswers.Should().BeEmpty(); }
public async Task Then_pages_has_active_status_set_correctly(string pageId, bool active) { await Handler.Handle(new ResetSectionAnswersRequest(ApplicationId, SequenceNo, SectionNo), CancellationToken.None); var pageResponse = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, pageId), CancellationToken.None); pageResponse.Value.Active.Should().Be(active); }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { if( _getPageHandler == null ) { Type type = typeof(System.Web.UI.Page).Assembly.GetType("System.Web.UI.PageHandlerFactory"); object obj = Activator.CreateInstance(type, true); //MethodInfo method = obj.GetType().GetMethod("GetHandler"); _getPageHandler = Delegate.CreateDelegate(typeof(GetPageHandler), obj, "GetHandler") as GetPageHandler; } if( _sso == null ) { _sso = new ArrayList(); string typeNames = System.Configuration.ConfigurationSettings.AppSettings["Map:SSOClass"]; if( !Util.IsNullOrEmpty(typeNames) ) { foreach( string typeName in typeNames.Split('|') ) { Type type = Type.GetType(typeName); ISSO sso = Activator.CreateInstance(type) as ISSO; _sso.Add(sso); } } } if( Util.IsNullOrEmpty(_connectionString) ) { Type type = Type.GetType("Mysoft.Map.Data.MyDB,Mysoft.Map.Core"); if( type != null ) { _connectionString = (string)type.InvokeMember("GetSqlConnectionString", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, null); if( _sso != null ) { foreach( ISSO sso in _sso ) { sso.ConnectionString = _connectionString; } } } } IHttpHandler handler = _getPageHandler(context, requestType, url, pathTranslated); Page page = handler as Page; if( page != null ) { page.Init += new EventHandler(page_Init); page.PreRender += new EventHandler(page_PreRender); } return handler; }
public async Task Then_all_pages_have_their_active_status_set_correctly() { await Handler.Handle(new ResetPageAnswersRequest(ApplicationId, SectionId, "1"), CancellationToken.None); var page1Response = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, "1"), CancellationToken.None); page1Response.Value.Active.Should().BeTrue(); var page2Response = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, "2"), CancellationToken.None); page2Response.Value.Active.Should().BeFalse(); var page3Response = await GetPageHandler.Handle(new GetPageRequest(ApplicationId, SectionId, "3"), CancellationToken.None); page3Response.Value.Active.Should().BeFalse(); }
public async Task SetUp() { DataContext = DataContextHelpers.GetInMemoryDataContext(); Handler = new ResetPageAnswersHandler(DataContext, new NotRequiredProcessor(), new TagProcessingService(DataContext)); GetApplicationDataHandler = new GetApplicationDataHandler(DataContext); GetPageHandler = new GetPageHandler(DataContext); ApplicationId = Guid.NewGuid(); SectionId = Guid.NewGuid(); await DataContext.ApplicationSections.AddAsync(new ApplicationSection() { ApplicationId = ApplicationId, Id = SectionId, QnAData = new QnAData() { Pages = new List <Page> { new Page() { PageId = "1", Questions = new List <Question> { new Question() { QuestionId = "Q1", QuestionTag = "Q1", Input = new Input() } }, PageOfAnswers = new List <PageOfAnswers> { new PageOfAnswers { Answers = new List <Answer> { new Answer { QuestionId = "Q1", Value = "Yes" } } } }, Next = new List <Next> { new Next() { Action = "NextPage", ReturnId = "2", Conditions = new List <Condition>() { new Condition { QuestionId = "Q1", MustEqual = "Yes" } } }, new Next() { Action = "NextPage", ReturnId = "3", Conditions = new List <Condition>() { new Condition { QuestionId = "Q1", MustEqual = "No" } } } }, Feedback = new List <Feedback> { new Feedback { IsCompleted = true } }, Active = true, Complete = true }, new Page() { PageId = "2", Questions = new List <Question> { new Question() { QuestionId = "Q2", Input = new Input() } }, PageOfAnswers = new List <PageOfAnswers>(), Next = new List <Next> { new Next() { Action = "ReturnToSequence", Conditions = new List <Condition>() }, }, Active = true, ActivatedByPageId = "1" }, new Page() { PageId = "3", Questions = new List <Question> { new Question() { QuestionId = "Q3", Input = new Input() } }, PageOfAnswers = new List <PageOfAnswers>(), Next = new List <Next> { new Next() { Action = "ReturnToSequence", Conditions = new List <Condition>() } }, Active = false, ActivatedByPageId = "1" } } } }); await DataContext.Applications.AddAsync(new Data.Entities.Application() { Id = ApplicationId, ApplicationData = "{ \"Q1\" : \"Yes\" }" }); await DataContext.SaveChangesAsync(); }