Example #1
0
        public List <List> Get(string id)
        {
            // id is the userToken, have to convert to userId
            var user = UserFactory.LoadSingleByToken(id);

            return(user == null ? null : ListFactory.LoadByUserId(Db, user.Id));
        }
Example #2
0
        public string GetHelpContentFromSharePoint(string heading, string sPContext, string helpListName,
                                                   string templateName)
        {
            if (!string.IsNullOrEmpty(heading))
            {
                heading = heading.Replace("\r", string.Empty).Trim();
                var query     = ListQueries.HelpGetItemQuery(templateName, heading);
                var helpList  = ListFactory.Create(helpListName, query);
                var presenter = new SharePointListPresenter(helpList, this);

                var fitem = presenter.GetHelpItems().FirstOrDefault();

                if (fitem != null)
                {
                    return(fitem.GetFieldValue(Constants.SharePointFields.Content));
                }

                var generalHelp = ListQueries.HelpGetItemQuery(templateName, Constants.SharePointFields.WizardHelp);
                helpList.UpdateCamlQuery(generalHelp);
                var gitem = presenter.GetHelpItems().FirstOrDefault();
                return(gitem != null
                    ? gitem.GetFieldValue(Constants.SharePointFields.Content)
                    : "Unable to find the help content for this document");
            }
            return("Unable to find the help content for this document");
        }
Example #3
0
        public void Should_leverage_repository_to_create_a_new_customer()
        {
            string username    = "******";
            string password    = "******";
            string firstName   = "mo";
            string lastName    = "khan";
            string phoneNumber = "4036813389";
            string city        = "calgary";
            RegisterCustomerDTO customerDTO =
                new RegisterCustomerDTO(username, password, firstName, lastName, phoneNumber, city);

            ICustomer     customer     = _mockery.DynamicMock <ICustomer>( );
            IRegistration registration = _mockery.DynamicMock <IRegistration>( );

            using (_mockery.Record( )) {
                SetupResult.For(customer.Registration( )).Return(registration);
                SetupResult.For(registration.IsValid( )).Return(true);

                Expect.Call(_mockCustomerRepository.NewCustomer( )).Return(customer);
                customer.RegisterAccount(username, password, firstName, lastName, phoneNumber, city);
            }

            using (_mockery.Playback( )) {
                ListFactory.From(CreateSUT( ).RegisterNew(customerDTO));
            }
        }
Example #4
0
        public static Dictionary <TKey, List <TValue> > BucketSort <TKey, TValue>(
            this IEnumerable <TValue> inputs,
            Func <TValue, bool> validator,
            KeySelector <TValue, TKey> keySelector,
            DictionaryFactory <TKey, List <TValue> > dictionaryFactory,
            ListFactory <TValue> listFactory)
        {
            var buckets = dictionaryFactory();

            foreach (var input in inputs)
            {
                if (!validator(input))
                {
                    continue;
                }
                var           keyValue = keySelector(input);
                List <TValue> eventsInBucket;
                if (!buckets.TryGetValue(keyValue, out eventsInBucket))
                {
                    eventsInBucket = listFactory();
                    buckets.Add(keyValue, eventsInBucket);
                }

                eventsInBucket.Add(input);
            }

            return(buckets);
        }
Example #5
0
        private List <IQuestionClass> LoadMinorQuestionTypes()
        {
            var list      = ListFactory.Create(Settings.Default.MinorQuestionClassesListName);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetMinorQuestionItems());
        }
Example #6
0
 private ArgumentListWrapper(
     Node <TParent, TParentSyntax> node,
     Func <TParentSyntax, SeparatedSyntaxList <ArgumentSyntax> > getList,
     Func <TParentSyntax, SeparatedSyntaxList <ArgumentSyntax>, TParentSyntax> createList)
     : this(ListFactory.CreateNodeList(node, getList, createList, ArgumentSyntaxExtensions.ToInternalArgument))
 {
 }
Example #7
0
        public void Shoud_return_no_broken_rules()
        {
            IRegistration           registration = CreateSUT("userName", "PASSWORD");
            IRichList <IBrokenRule> brokenRules  = ListFactory.From(registration.BrokenRules( ));

            Assert.AreEqual(0, brokenRules.Count);
        }
Example #8
0
 public Customer(long id, IEnumerable <IBoat> registeredBoats, IEnumerable <ISlipLease> leases,
                 IRegistration registration) : base(id)
 {
     _registeredBoats = ListFactory.From(registeredBoats);
     _leases          = ListFactory.From(leases);
     _registration    = registration;
 }
Example #9
0
        public void TestUpdateListBlankName()
        {
            var id = ListFactory.CreateNewList(Db, UserToken);

            if (id == null)
            {
                Assert.Fail();
            }
            else
            {
                // First update to normal name
                var testListName = "Normal Name";
                ListFactory.UpdateListName(Db, (int)id, testListName);

                // Then try to update it to be blank
                ListFactory.UpdateListName(Db, (int)id, "");

                var testList = ListFactory.LoadSingle(Db, (int)id);

                // Make sure the name of the list is the old name, not blank
                Assert.IsNotNull(testList);
                Assert.AreEqual(testListName, testList.Name);

                ListFactory.DeleteList(Db, (int)id);
            }
        }
        private void LoadClaimsProcedures(TaskScheduler uiScheduler)
        {
            List <ISharePointListItem> fragments = null;

            if (Cache.Contains(Constants.CacheNames.RenLtrFragments))
            {
                fragments = (List <ISharePointListItem>)Cache.Get(Constants.CacheNames.RenLtrFragments);
            }
            else
            {
                var list      = ListFactory.Create(Settings.Default.LibraryClaimsProcedures);
                var presenter = new SharePointListPresenter(list, this);
                fragments = presenter.GetItems();
            }


            if (uiScheduler == null)
            {
                DataBindClaimsControl(fragments);
            }
            else
            {
                Task.Factory.StartNew(() => DataBindClaimsControl(fragments), CancellationToken.None,
                                      TaskCreationOptions.None, uiScheduler);
            }
        }
Example #11
0
 public QueryExpressionListWrapper(
     Node <TParent, TParentSyntax> node,
     Func <TParentSyntax, SyntaxList <QueryClauseSyntax> > getList,
     Func <TParentSyntax, SyntaxList <QueryClauseSyntax>, TParentSyntax> createList)
     : this(ListFactory.CreateNodeList(node, getList, createList, QueryClauseSyntaxExtensions.ToInternalQueryExpression))
 {
 }
Example #12
0
        protected List <IQuestionClass> LoadQuestionsFromSharePoint(string contextUrl, string listName)
        {
            var list      = ListFactory.Create(listName, true);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetPreRenewalQuestionaireQuestions());
        }
Example #13
0
        public double GetKd(string StructureTypeId)
        {
            #region Read Table

            var SampleValue = new { StructureTypeId = "", Description = "", Kd = "" }; // sample
            var KdList      = ListFactory.MakeList(SampleValue);

            using (StringReader reader = new StringReader(Resources.ASCE7_10F26_6_1Kd))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] Vals = line.Split(',');
                    if (Vals.Count() == 3)
                    {
                        string thisStructureTypeId = (string)Vals[0];
                        string thisDescription     = (string)Vals[1];
                        string thisKd = (string)Vals[2];

                        KdList.Add(new
                        {
                            StructureTypeId = thisStructureTypeId,
                            Description     = thisDescription,
                            Kd = thisKd
                        });
                    }
                }
            }

            #endregion

            var tableValues = from KdEntry in KdList
                              where (KdEntry.StructureTypeId == StructureTypeId)
                              select KdEntry;
            var result = (tableValues.ToList()).FirstOrDefault();

            double Kd = 1.0;
            if (result != null)
            {
                Kd = double.Parse(result.Kd, CultureInfo.InvariantCulture);
                string SystemDescription = result.Description;

                #region Kd
                ICalcLogEntry KdEntry = new CalcLogEntry();
                KdEntry.ValueName = "Kd";
                KdEntry.AddDependencyValue("SystemDescription", SystemDescription);
                KdEntry.Reference            = "";
                KdEntry.DescriptionReference = "/Templates/Loads/ASCE7_10/Wind/WindDirectionalityFactor.docx";
                KdEntry.FormulaID            = null; //reference to formula from code
                KdEntry.VariableValue        = Math.Round(Kd, 2).ToString();
                #endregion
                this.AddToLog(KdEntry);
            }
            else
            {
                throw new ParameterNotFoundInTableException("Kd");
            }

            return(Kd);
        }
Example #14
0
        public static Dictionary <TKey, List <TValue> > BucketSort <TKey, TValue>(
            this ArraySegment <TValue> inputs,
            Func <TValue, bool> validator,
            KeySelector <TValue, TKey> keySelector,
            DictionaryFactory <TKey, List <TValue> > dictionaryFactory,
            ListFactory <TValue> listFactory)
        {
            var buckets = dictionaryFactory();

            for (int x = 0; x < inputs.Count; x++)
            {
                var input = inputs.Array[x];
                if (!validator(input))
                {
                    continue;
                }

                var           keyValue = keySelector(input);
                List <TValue> eventsInBucket;
                if (!buckets.TryGetValue(keyValue, out eventsInBucket))
                {
                    eventsInBucket = listFactory();
                    buckets.Add(keyValue, eventsInBucket);
                }

                eventsInBucket.Add(input);
            }

            return(buckets);
        }
Example #15
0
 private static object Convert(Type type, object value)
 {
     if (type == typeof(object))
     {
         var entity = value as InMemoryEntity;
         return(entity != null &&
                typeof(Abstract1CEntity).IsAssignableFrom(entity.entityType)
             ? CreateEntity(entity.entityType, entity)
             : value);
     }
     if (typeof(IList).IsAssignableFrom(type))
     {
         var oldList  = (IList)value;
         var itemType = type.GetGenericArguments()[0];
         var newList  = ListFactory.Create(itemType, null, oldList.Count);
         foreach (InMemoryEntity l in oldList)
         {
             newList.Add(CreateEntity(itemType, l));
         }
         return(newList);
     }
     return(typeof(Abstract1CEntity).IsAssignableFrom(type) && value != null
         ? CreateEntity(type, (InMemoryEntity)value)
         : value);
 }
Example #16
0
        public BuildingRiskCategory GetRiskCategory(string structureCategoryByOccupancyId)
        {
            #region Read Category Data (ASCE Table 1.5-1)

            var SampleValue      = new { OccupancyId = "", OccupancyDescription = "", RiskCategory = "" }; // sample
            var RiskCategoryList = ListFactory.MakeList(SampleValue);

            using (StringReader reader = new StringReader(Resources.ASCE7_10T1_5_1RiskCategories))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] Vals = line.Split(',');
                    if (Vals.Count() == 3)
                    {
                        string OccupId = (string)Vals[0];
                        string OccupancyDescription = (string)Vals[1];
                        string RiskCat = (string)Vals[2];


                        RiskCategoryList.Add(new
                        {
                            OccupancyId          = OccupId,
                            OccupancyDescription = OccupancyDescription,
                            RiskCategory         = RiskCat
                        });
                    }
                }
            }

            #endregion

            var dataValues     = from riskCat in RiskCategoryList where (riskCat.OccupancyId == structureCategoryByOccupancyId) select riskCat;
            var resultCategory = dataValues.ToList().First();

            string parsedCategoryValue        = resultCategory.RiskCategory;
            string parsedOccupancyDescription = resultCategory.OccupancyDescription;

            BuildingRiskCategory riskCategory = BuildingRiskCategory.None;
            BuildingRiskCategory tmpParsedVal;
            if (Enum.TryParse <BuildingRiskCategory>(parsedCategoryValue, false, out tmpParsedVal) == true)
            {
                riskCategory = tmpParsedVal;
            }


            #region RiskCategory
            ICalcLogEntry riskCategoryEntry = new CalcLogEntry();
            riskCategoryEntry.ValueName = "RiskCategory";
            riskCategoryEntry.AddDependencyValue("OccupancyDescription", parsedOccupancyDescription);
            riskCategoryEntry.Reference            = "Risk Category";
            riskCategoryEntry.DescriptionReference = "/Templates/General/RiskCategory.docx";
            riskCategoryEntry.FormulaID            = "Table 1.5-1"; //reference to formula from code
            riskCategoryEntry.VariableValue        = riskCategory.ToString();
            #endregion
            this.AddToLog(riskCategoryEntry);

            return(riskCategory);
        }
        protected IManualClaimsProcedure LoadClaimsProcedure(string contextUrl, string listName, string title)
        {
            var list      = ListFactory.Create(listName, ListQueries.GetItemByPolicyTypeQuery(title));
            var presenter = new SharePointListPresenter(list, this);
            var t         = presenter.GetManualClaimsProcedure();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
Example #18
0
        public void Should_be_able_to_register_a_new_boat()
        {
            ICustomer customer = CreateSUT( );

            Assert.AreEqual(0, ListFactory.From(customer.RegisteredBoats( )).Count);
            customer.RegisterBoat(ObjectMother.Boat( ));
            Assert.AreEqual(1, ListFactory.From(customer.RegisteredBoats( )).Count);
        }
Example #19
0
        protected IQuestionClass LoadSchedule(string contextUrl, string listName, string title)
        {
            var list      = ListFactory.Create(listName, ListQueries.GetItemByTitleQuery(title));
            var presenter = new SharePointListPresenter(list, this);
            var t         = presenter.GetPreRenewalQuestionaireQuestions();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
    public List <T> Build <T>()
    {
        var factory     = new ListFactory <T>(size);
        var list        = factory.Create();
        var initializer = new ListInitializer <T>(default(T), size);

        initializer.Initialize(list);
        return(list);
    }
Example #21
0
        public void Should_not_allow_blank_username()
        {
            string                  blankUserName = string.Empty;
            IRegistration           registration  = CreateSUT(blankUserName, "password");
            IRichList <IBrokenRule> brokenRules   = ListFactory.From(registration.BrokenRules( ));

            Assert.IsFalse(registration.IsValid( ));
            Assert.AreEqual("Username cannot be blank", brokenRules[0].Message( ));
        }
Example #22
0
        public void Should_return_at_least_one_available_slip_for_the_dock()
        {
            ISlipsRepository repository = CreateSUT( );
            IDock            dock       = new Dock(1, string.Empty, null, null);

            IRichList <ISlip> slipsFound = ListFactory.From(repository.AllAvailableSlipsFor(dock));

            Assert.IsTrue(slipsFound.Count > 0);
        }
Example #23
0
        private void ResetContext(string url)
        {
            _provider.SiteUrl = url;
            var context = _provider.Create();

            _contentTypeFactory = new ContentTypeFactory(context);
            _listFactory        = new ListFactory(context);
            _service            = new SharepointService(context);
        }
Example #24
0
        private List <IQuoteSlipSchedules> GetQuestionsForIncludedPolicies(string includedPolicies)
        {
            var spList    = ListFactory.Create("Quote Slip Schedules");
            var presenter = new SharePointListPresenter(spList, this);
            var items     = presenter.GetItems();


            var spListQuestions = ListFactory.Create(Settings.Default.PreRenewalQuestionareMappingsListName);
            //todo: move listname to settings
            var presenterQuestions = new SharePointListPresenter(spListQuestions, this);
            var itemsQuestions     = presenterQuestions.GetItems();


            var qs = includedPolicies.Split(';').Select(delegate(string p)
            {
                if (string.IsNullOrEmpty(p))
                {
                    p = "-123";
                }
                //saftey net incase there are any blank lookup values in sharepoint, better not to display them in the popup

                var g =
                    items.FirstOrDefault(
                        i =>
                        i.GetLookupFieldValueIdArray(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId)
                        .Contains(p));         //presenter.GetQuoteSlipSchedule(p);
                var title = string.Empty;

                if (g != null)
                {
                    title = g.Title;

                    if (g.Title.ToLower().Contains("workers"))
                    {
                        var question =
                            itemsQuestions.FirstOrDefault(i => i.GetFieldValue(Constants.SharePointFields.FieldId) == p);
                        //presenter.GetQuoteSlipSchedule(p);

                        title = question.Title;
                    }
                }

                return(g == null
                    ? null
                    : new QuoteSlipSchedules
                {
                    Title = title,
                    Url = g.FileRef,
                    Id = g.GetFieldValue(Constants.SharePointFields.FieldId),
                    LinkedQuestionId =
                        g.GetLookupFieldValueIdArray(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId)
                });
            }).Cast <IQuoteSlipSchedules>().ToList();

            return(qs);
        }
Example #25
0
        public void Should_return_all_leases_for_a_specific_customer()
        {
            long customerId = CustomerMother.CreateCustomerRecord( );

            LeaseMother.CreateLeaseFor(customerId);

            IRichList <ISlipLease> leasesForCustomer = ListFactory.From(CreateSUT( ).AllLeasesFor(customerId));

            Assert.AreEqual(1, leasesForCustomer.Count);
        }
Example #26
0
        public void Should_be_able_to_lease_a_slip()
        {
            ICustomer      customer = CreateSUT( );
            ISlip          slip     = ObjectMother.Slip( );
            ILeaseDuration duration = LeaseDurations.Monthly;

            customer.Lease(slip, duration);

            Assert.AreEqual(1, ListFactory.From(customer.Leases( )).Count);
        }
        public void Clear_ZeroesAllBits()
        {
            var bitAggregate = new BitAggregate(MockBitFactory.CreateMockBits(0, 1, 0, 0, 1, 1, 0, 0));

            bitAggregate.Clear();

            var bitValues = bitAggregate.Read();

            Assert.Equal(bitValues, ListFactory.CreateList(0, 0, 0, 0, 0, 0, 0, 0));
        }
Example #28
0
        public void Should_return_3_boats()
        {
            long customerId = CustomerMother.CreateCustomerRecord( );

            BoatMother.AddBoatsFor(customerId);

            IRichList <IBoat> boats = ListFactory.From(CreateSUT( ).AllBoatsFor(customerId));

            Assert.AreEqual(3, boats.Count);
        }
Example #29
0
        public static BaseList GetList([NotNull] Uri webUrl, [NotNull] string listName, [NotNull] SpContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            Assert.ArgumentNotNull(webUrl, "webUrl");
            Assert.ArgumentNotNull(listName, "listName");

            var connector = new ListConnector(context, webUrl);

            return(ListFactory.CreateListObject(connector.GetList(listName), webUrl, context));
        }
Example #30
0
        public void Should_not_be_able_to_register_an_already_registered_boat()
        {
            ICustomer customer = CreateSUT( );
            IBoat     boat     = ObjectMother.Boat( );

            customer.RegisterBoat(boat);
            customer.RegisterBoat(boat);

            Assert.AreEqual(1, ListFactory.From(customer.RegisteredBoats( )).Count);
        }