Exemple #1
0
        public static Person CreateSavePerson(CMSDataContext db, Family family = null, string lastName = null)
        {
            if (family == null)
            {
                family = new Family()
                {
                    CreatedDate = DateTime.Now
                };
                db.Families.InsertOnSubmit(family);
                db.SubmitChanges();
            }
            var person = new Person
            {
                Family             = family,
                FirstName          = DatabaseTestBase.RandomString(),
                LastName           = lastName ?? DatabaseTestBase.RandomString(),
                EmailAddress       = DatabaseTestBase.RandomString() + "@example.com",
                MemberStatusId     = MemberStatusCode.Member,
                PositionInFamilyId = PositionInFamily.PrimaryAdult,
            };

            db.People.InsertOnSubmit(person);
            db.SubmitChanges();

            return(person);
        }
        public static Organization CreateOrganization(CMSDataContext db, string orgName = null, int?campusId = null, int?fromId = null, int?type = null)
        {
            Organization org    = null;
            var          newOrg = new Organization();

            if (fromId != null)
            {
                org = db.LoadOrganizationById(fromId);
            }
            if (org == null)
            {
                org = db.Organizations.First();
            }

            newOrg.CreatedDate          = DateTime.Now;
            newOrg.CreatedBy            = 0;
            newOrg.OrganizationName     = orgName ?? DatabaseTestBase.RandomString();
            newOrg.EntryPointId         = org.EntryPointId;
            newOrg.OrganizationTypeId   = type ?? org.OrganizationTypeId;
            newOrg.OrganizationStatusId = 30;
            newOrg.DivisionId           = org.DivisionId;
            newOrg.CampusId             = campusId;

            db.Organizations.InsertOnSubmit(newOrg);
            db.SubmitChanges();

            return(newOrg);
        }
Exemple #3
0
        public static GatewayAccount CreateMockPaymentProcessor(CMSDataContext db, PaymentProcessTypes processType, GatewayTypes gatewayType)
        {
            GatewayAccount account        = null;
            var            paymentProcess = db.PaymentProcess.Single(x => x.ProcessId == (int)processType);

            if (paymentProcess.GatewayAccountId.HasValue)
            {
                account = db.GatewayAccount.First(a => a.GatewayAccountId == paymentProcess.GatewayAccountId);
            }
            if (account == null)
            {
                account = db.GatewayAccount.First(a => a.GatewayAccountId == (int)gatewayType);
                paymentProcess.GatewayAccountId = account.GatewayAccountId;
                var details = db.GatewayDetails.Where(d => d.GatewayAccountId == account.GatewayAccountId).ToList();
                foreach (var d in details)
                {
                    if (d.GatewayDetailName == "GatewayTesting")
                    {
                        d.GatewayDetailValue = "true";
                    }
                    else if (!d.IsBoolean && !d.GatewayDetailValue.HasValue())
                    {
                        d.GatewayDetailValue = DatabaseTestBase.RandomString();
                    }
                }
                db.SubmitChanges();
            }
            return(account);
        }
Exemple #4
0
        public static ContributionFund CreateSaveFund(CMSDataContext db, bool isPledge)
        {
            int    fundId;
            Random random       = new Random();
            bool   fundIdExists = false;

            do
            {
                fundId       = random.Next(1000);
                fundIdExists = db.ContributionFunds.Any(f => f.FundId == fundId);
            } while (fundIdExists);

            var fund = new ContributionFund
            {
                FundId         = fundId,
                FundName       = DatabaseTestBase.RandomString(),
                FundPledgeFlag = isPledge,
                CreatedBy      = 1,
                CreatedDate    = DateTime.Now
            };

            db.ContributionFunds.InsertOnSubmit(fund);
            db.SubmitChanges();
            return(fund);
        }
Exemple #5
0
 public static void CreateSaveGatewayDetails(CMSDataContext db, GatewayAccount gatewayAccount, IQueryable <GatewayConfigurationTemplate> template)
 {
     foreach (var item in template)
     {
         var detail = new GatewayDetails
         {
             GatewayAccountId   = gatewayAccount.GatewayAccountId,
             GatewayDetailName  = item.GatewayDetailName,
             GatewayDetailValue = item.IsBoolean ? "true" : DatabaseTestBase.RandomString(),
             IsBoolean          = item.IsBoolean
         };
         db.GatewayDetails.InsertOnSubmit(detail);
         db.SubmitChanges();
     }
 }
Exemple #6
0
        public static GatewayAccount CreateSaveGatewayAccount(CMSDataContext db, GatewayTypes gatewayType)
        {
            var gatewayAccount = new GatewayAccount();
            var gateway        = db.Gateways.FirstOrDefault(p => p.GatewayId == (int)gatewayType);

            if (gateway != null)
            {
                gatewayAccount.GatewayAccountName = DatabaseTestBase.RandomString();
                gatewayAccount.GatewayId          = gateway.GatewayId;
                db.GatewayAccount.InsertOnSubmit(gatewayAccount);
                db.SubmitChanges();
                var template = db.GatewayConfigurationTemplate.Where(p => p.GatewayId == gateway.GatewayId);
                CreateSaveGatewayDetails(db, gatewayAccount, template);
                db.SubmitChanges();
            }
            return(gatewayAccount);
        }
        public MockHttpContext(bool isAuthenticated = true)
        {
            Items        = new Dictionary <string, object>();
            MockRequest  = new Mock <HttpRequestBase>();
            MockResponse = new Mock <HttpResponseBase>();
            var session         = new Mock <HttpSessionStateBase>();
            var server          = new Mock <HttpServerUtilityBase>();
            var user            = new Mock <IPrincipal>();
            var identity        = new Mock <IIdentity>();
            var responseBody    = new StringBuilder();
            var cachePolicyBase = new Mock <HttpCachePolicyBase>();

            Headers         = new NameValueCollection();
            ServerVariables = new NameValueCollection {
                { "HTTP_X_FORWARDED_FOR", null },
                { "REMOTE_ADDR", "::1" }
            };
            var cookies = new HttpCookieCollection();

            user.Setup(usr => usr.Identity).Returns(identity.Object);
            identity.SetupGet(ident => ident.IsAuthenticated).Returns(isAuthenticated);
            MockRequest.SetupGet(r => r.Url).Returns(new Uri(Url));
            MockRequest.SetupGet(r => r.QueryString).Returns(new NameValueCollection {
            });
            MockRequest.SetupGet(r => r.ServerVariables).Returns(ServerVariables);
            MockRequest.SetupGet(r => r.Headers).Returns(Headers);
            MockRequest.SetupGet(r => r.Cookies).Returns(cookies);

            MockResponse.SetupGet(ctx => ctx.Output).Returns(new StringWriter(responseBody));
            MockResponse.SetupGet(ctx => ctx.Cache).Returns(cachePolicyBase.Object);

            session.SetupGet(s => s.SessionID).Returns(DatabaseTestBase.RandomString());

            SetupGet(ctx => ctx.Request).Returns(MockRequest.Object);
            SetupGet(ctx => ctx.Response).Returns(MockResponse.Object);
            SetupGet(ctx => ctx.Session).Returns(session.Object);
            SetupGet(ctx => ctx.Server).Returns(server.Object);
            SetupGet(ctx => ctx.User).Returns(user.Object);
            SetupGet(ctx => ctx.Items).Returns(Items);
            SetupGet(ctx => ctx.Cache).Returns(HttpRuntime.Cache);
        }