Example #1
0
        public static Link CreateLinkFromReader(IDnaDataReader reader)
        {
            Link link = new Link();
            link.Type = reader.GetStringNullAsEmpty("destinationtype");

            link.LinkId = reader.GetInt32NullAsZero("linkid");
            link.TeamId =  reader.GetInt32NullAsZero("teamid");
            link.Relationship =  reader.GetStringNullAsEmpty("relationship");
            link.Private =  reader.GetTinyIntAsInt("private");
            link.Description = reader.GetStringNullAsEmpty("linkdescription");
            link.DateLinked = new DateElement(reader.GetDateTime("DateLinked"));

            link.Submitter = new UserElement() { user = BBC.Dna.Objects.User.CreateUserFromReader(reader, "submitter") };

            //Create appropriate URL from link type. 
            int destinationId = reader.GetInt32NullAsZero("DestinationID");
            switch (link.Type)
            {
                case "article":
                {
                    link.DnaUid =  "A" + destinationId.ToString();
                    break;
                }
                case "userpage":
                {
                    link.DnaUid =  "U" + destinationId.ToString();
                    break;
                }
                case "category":
                {
                    link.DnaUid =  "C" + destinationId.ToString();
                    break;
                }
                case "forum":
                {
                    link.DnaUid =  "F" + destinationId.ToString();
                    break;
                }
                case "thread":
                {
                    link.DnaUid =  "T" + destinationId.ToString();
                    break;
                }
                case "posting":
                {
                    link.DnaUid =  "TP" + destinationId.ToString();
                    break;
                }
                default: // "club" )
                {
                    link.DnaUid =  "G" + destinationId.ToString();
                    break;
                }
            }
            return link;
        }
Example #2
0
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        public static Link CreateLink()
        {
            Link target = new Link()
            {
                Type = "article",
                DateLinked = new DateElement(DateTime.Now),
                DnaUid = "123456",
                Description = "Here is my Test Link",
                LinkId = 1,
                Private = 0,
                Relationship = "Bookmark",
                Submitter = new UserElement() { user = UserTest.CreateTestUser() },
                TeamId = 1
            };
            return target;
        }