/// <summary> /// Initializes resolvers. /// </summary> static ModelResolvers() { Mock <ExpressionResolver> exprResolverMock = new Mock <ExpressionResolver>(); exprResolverMock.Setup(o => o(null)).Returns(() => { return(new Expression()); }); exprResolverMock.Setup(o => o(It.IsNotNull <IExpression>())).Returns((IExpression parentExpr) => { return(new Expression(parentExpr)); }); Mock <RuleExpressionResolver> ruleExprResolverMock = new Mock <RuleExpressionResolver>(); ruleExprResolverMock.Setup(o => o(It.IsNotNull <IExpression>(), It.IsAny <IRuleset>(), It.IsAny <string>(), It.IsAny <int?>())) .Returns((IExpression expression, IRuleset containingRuleset, string errorCode, int?errorLevel) => { return(new RuleExpression(expression, containingRuleset, errorCode, errorLevel)); }); Mock <JoinExpressionResolver> joinExprResolverMock = new Mock <JoinExpressionResolver>(); joinExprResolverMock.Setup(o => o(It.IsNotNull <IExpression>())).Returns((IExpression expression) => { return(new JoinExpression(expression)); }); Mock <DataStructureResolver> dsResolverMock = new Mock <DataStructureResolver>(); dsResolverMock.Setup(o => o(null, null, null)).Returns(() => { return(new DataStructure()); }); dsResolverMock.Setup(o => o(It.IsNotNull <string>(), It.IsNotNull <ComponentType?>(), It.IsNotNull <BasicDataType?>())) .Returns((string compName, ComponentType? compType, BasicDataType? dataType) => { return(new DataStructure(compName, (ComponentType)compType, (BasicDataType)dataType)); }); Mock <TransformationSchemaResolver> schemaResolverMock = new Mock <TransformationSchemaResolver>(); schemaResolverMock.Setup(o => o()).Returns(() => { return(new TransformationSchema()); }); ModelResolvers.ExprResolver = exprResolverMock.Object; ModelResolvers.RuleExprResolver = ruleExprResolverMock.Object; ModelResolvers.JoinExprResolver = joinExprResolverMock.Object; ModelResolvers.DsResolver = dsResolverMock.Object; ModelResolvers.SchemaResolver = schemaResolverMock.Object; ModelResolvers.OperatorResolver = ModelResolvers.InitOperatorResolver(); }
public GetOperatorTests() { Mock <IDataModelProvider> dataModelMock = new Mock <IDataModelProvider>(); dataModelMock.Setup(o => o.GetDatasetStructure(It.IsAny <string>())).Returns((string dsName) => this.GetDataStructure(dsName)); Mock <OperatorResolver> opResolverMock = new Mock <OperatorResolver>(); opResolverMock.Setup(o => o("get")).Returns(() => { return(new GetOperator(dataModelMock.Object)); }); this._opResolver = opResolverMock.Object; }
public CompCreateOperatorTests() { Mock <OperatorResolver> opResolverMock = new Mock <OperatorResolver>(); opResolverMock.Setup(o => o("calcExpr")).Returns(() => { return(new CalcExprOperator(ModelResolvers.DsResolver)); }); opResolverMock.Setup(o => o("comp")).Returns(new ComponentOperator(ModelResolvers.DsResolver, new ComponentTypeInference(ModelResolvers.DsResolver))); opResolverMock.Setup(o => o("join")).Returns(new JoinOperator(ModelResolvers.DsResolver)); this._opResolver = opResolverMock.Object; this._operators = new List <string>() { "calcExpr" }; }
protected void Page_Load(object sender, EventArgs e) { try { Int32 nooflegs = Int32.Parse(Request.Params.Get("nooflegs")); BookRequest b = new BookRequest(); Customer check = CustomerBO.GetLoggedInCustomer(); Agent agentcheck = AgentBO.GetLoggedInAgent(); b.IsAgent = false; Contact c = new Contact(); if (check != null) { c.Name = check.Name; c.Email = check.Email; c.Phone = check.ContactNo; } else { c.Name = Request.Params.Get("Name"); c.Email = Request.Params.Get("Email"); c.Phone = Request.Params.Get("ContactNo"); if (agentcheck != null) { b.IsAgent = true; b.Agent = agentcheck; } else if (Session["AgentID"] != null) { b.IsAgent = true; Agent a = AgentDAO.FindAgentByID((long)Session["AgentID"]); b.Agent = a; } else { Customer custemail = CustomerDAO.CheckCustomerByEmail(Request.Params.Get("Email")); if (custemail == null) { Customer cust = new Customer(); cust.Email = Request.Params.Get("Email");; cust.ContactNo = Request.Params.Get("ContactNo"); cust.Name = Request.Params.Get("Name"); cust.Password = CustomerBO.GeneratePassword(); cust.Status = 1; CustomerDAO.MakePersistent(cust); check = cust; EmailBO em = new EmailBO("NewCustomer", Session["Country"].ToString()); em.SendEmailToCustomer(check); } else { check = custemail; } } } if (Request.Params.Get("fixedpricecharter") != null) { FixedPriceCharter el = BookRequestDAO.FindFixedPriceCharterByID(Int64.Parse(Request.Params.Get("fixedpricecharter"))); b.FixedPriceCharter = el; } c.Description = Request.Params.Get("OtherDetails"); b.PAX = Int32.Parse(Request.Params.Get("PAX")); b.Budget = Double.Parse(Request.Params.Get("budget")); b.FinalBudget = BookRequestBO.GetFinalBudget(b.Budget, AdminBO.GetCountry()); b.ContactDetails = c; b.TimeofCreation = DateTime.Now; b.TripType = Request.Params.Get("TripType"); AirplaneType apt = OperatorDAO.FindAircraftTypeByID(Request.Params.Get("aircrafttype")); b.PlaneType = apt; b.Status = 0; b.Domain = AdminDAO.GetCountryByID(Session["Country"].ToString()); for (int i = 1; i <= nooflegs; i++) { Leg l = new Leg(); l.Sequence = i; ListSet fromairfields = AirfieldBO.GetAirfields(Request.Params.Get("fromleg" + i)); ListSet toairfields = AirfieldBO.GetAirfields(Request.Params.Get("toleg" + i)); foreach (Airfield a in fromairfields) { if (l.Source == null) { l.Source = a; } } if (l.Source.IsTemporary()) { l.Source = AirfieldBO.SaveAirfield(l.Source); } foreach (Airfield a in toairfields) { if (l.Destination == null) { l.Destination = a; } } if (l.Destination.IsTemporary()) { l.Destination = AirfieldBO.SaveAirfield(l.Destination); } l.Date = DateTime.Parse(Request.Params.Get("dateleg" + i) + " " + Request.Params.Get("timeleg" + i)); b.AddLeg(l); } b = BookRequestBO.AcceptBookRequest(b); if (b.FixedPriceCharter == null) { OperatorResolver opr = new OperatorResolver(OperatorBO.OperatorResolve); opr.BeginInvoke(b, null, null); } else { EmailBO em = new EmailBO("FixedPriceCharterNotificationToOperator", Session["Country"].ToString()); em.SendEmailToOperator(b.FixedPriceCharter.Aircraft.Vendor); } if (b.IsAgent) { EmailBO em = new EmailBO("AgentThanksRequest", Session["Country"].ToString()); em.SendEmailToAgent(b.Agent); } else { EmailBO em = new EmailBO("CustomerThanksRequest", Session["Country"].ToString()); em.SendEmailToCustomer(check); } Session.Add("bid", b.BookID); } catch (AifieldNotFoundException ax) { Response.Redirect(Request.UrlReferrer.OriginalString + "?" + Serialize(Request.QueryString)); } catch (Exception ex) { Response.Redirect("QuickQuote.aspx"); } Response.Redirect("RequestSent.aspx"); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionFactory"/> class. /// </summary> /// <param name="exprResolver">The expression resolver.</param> /// <param name="ruleExprResolver">The rule expression resolver.</param> /// <param name="joinExprResolver">The join expression resolver.</param> /// <param name="opResolver">The operator resolver.</param> public ExpressionFactory(ExpressionResolver exprResolver, RuleExpressionResolver ruleExprResolver, JoinExpressionResolver joinExprResolver, OperatorResolver opResolver) { this.ExprResolver = exprResolver; this.RuleExprResolver = ruleExprResolver; this.OperatorResolver = opResolver; this.JoinExprResolver = joinExprResolver; }
/// <summary> /// Initializes a new instance of the <see cref="TypeInferenceModifier"/> class. /// </summary> /// <param name="opResolver">The operator resolver.</param> /// <param name="dataModel">The data model.</param> public TypeInferenceModifier(OperatorResolver opResolver, IDataModelProvider dataModel) { this._opResolver = opResolver; this._dataModel = dataModel; }