public Jot GetJotById(JitterUser user, int jot_id)
 {
     // IQueryable that contains a single JitterUser
     var query = from u in _context.JitterUsers where u.JitterUserId == user.JitterUserId select u;
     JitterUser found_user = query.Single<JitterUser>();
     var query2 = from jot in found_user.Jots where jot.JotId == jot_id select jot;
     Jot found_jot = query2.Single<Jot>();
     return found_jot;
 }
Esempio n. 2
0
        public int CompareTo(object obj)
        {
            // Let's sort user based on their Handles b/c handles are strings AND...
            // .NET knows how to compare strings already. ha!

            // We need to explicitly cast from object type to JitterUser Type
            JitterUser other_user = obj as JitterUser;
            int        answer     = this.Handle.CompareTo(other_user.Handle);

            return(answer);
        }
 public void JitterUserEnsureUserHasJots()
 {
     List<Jot> list_of_jots = new List<Jot>
     {
         new Jot { Content = "blah" },
         new Jot { Content = "blah 2" }
     };
     JitterUser a_user = new JitterUser { Handle = "adam1", Jots = list_of_jots };
     List<Jot> actual_jots = a_user.Jots;
     CollectionAssert.AreEqual(list_of_jots, actual_jots);
 }
 public void JitterUserEnsureUserHasJots()
 {
     // Arrange
     List<Jot> list_of_jots = new List<Jot>
     {
         new Jot { Content = "blah!"},
         new Jot { Content = "blah part 2!"}
     };
     JitterUser a_user = new JitterUser { Handle = "adam1", Jots = list_of_jots};
     // Act
     List<Jot> actual_jots = a_user.Jots;
     // Assert
     CollectionAssert.AreEqual(list_of_jots, actual_jots);
 }
 public void JitterUserEnsureUserFollowsOthers()
 {
     // Arrange
     List<JitterUser> list_of_users = new List<JitterUser>
     {
         new JitterUser { Handle = "blah"},
         new JitterUser { Handle = "blah2"}
     };
     JitterUser a_user = new JitterUser { Handle = "adam1", Following = list_of_users };
     // Act
     List<JitterUser> actual_users = a_user.Following;
     // Assert
     CollectionAssert.AreEqual(list_of_users, actual_users);
 }
 public void JitterUserEnsureUserFollowOthers()
 {
     List<JitterUser> list_of_users = new List<JitterUser>
     {
         new JitterUser {Handle="blah" },
         new JitterUser {Handle="blah2" }
     };
     JitterUser a_user = new JitterUser
     {
         Handle = "adam1",
         Following = list_of_users
     };
     List<JitterUser> actual = a_user.Following;
     CollectionAssert.AreEqual(actual, list_of_users);
 }
Esempio n. 7
0
        public bool IsHandleAvailable(string handle)
        {
            bool available = false;

            try
            {
                JitterUser some_user = GetUserByHandle(handle);
                if (some_user == null)
                {
                    available = true;
                }
            }
            catch (InvalidOperationException) {}

            return(available);
        }
 public void JitterUserEnsureJitterUserHasAllTheThings()
 {
     JitterUser a_user = new JitterUser();
     a_user.Handle = "adam1";
     a_user.FirstName = "Adam";
     a_user.LastName = "Sandler";
     a_user.Picture = "https://google.com";
     a_user.Description = "I am awesome!";
     //Act
     //Assert
     Assert.AreEqual("adam1", a_user.Handle);
     Assert.AreEqual("Adam", a_user.FirstName);
     Assert.AreEqual("Sandler", a_user.LastName);
     Assert.AreEqual("I am awesome!", a_user.Description);
     Assert.AreEqual("https://google.com", a_user.Picture);
 }
Esempio n. 9
0
        public void JitterUserEnsureJitterUserHasAllTheThings()
        {
            // Arrange
            JitterUser a_user = new JitterUser();
            a_user.Handle = "solo1";
            a_user.FirstName = "Han";
            a_user.LastName = "Solo";
            a_user.Picture = "https://google.com";
            a_user.Description = "You've never heard of the Millennium Falcon? It's the ship that made the Kessel Run in less than twelve parsecs.";

            // Act

            // Assert
            Assert.AreEqual("solo1", a_user.Handle);
            Assert.AreEqual("Han", a_user.FirstName);
            Assert.AreEqual("Solo", a_user.LastName);
            Assert.AreEqual("https://google.com", a_user.Picture);
            Assert.AreEqual("You've never heard of the Millennium Falcon? It's the ship that made the Kessel Run in less than twelve parsecs.", a_user.Description);
        }
Esempio n. 10
0
 public bool CreateJot(JitterUser jitter_user1, string content)
 {
     Jot a_jot = new Jot { Content = content, Date = DateTime.Now, Author = jitter_user1 };
     bool is_added = true;
     try
     {
         Jot added_jot = _context.Jots.Add(a_jot);
         _context.SaveChanges();
         // Why is this null? Are the doc inaccurate?
         /*
         if (added_jot == null)
         {
           is_added = false;
         }*/
     } catch (Exception)
     {
         is_added = false;
     }
     return is_added;
 }
 public bool CreateJitterUser(ApplicationUser app_user, string new_handle)
 {
     bool handle_is_available = this.IsHandleAvailable(new_handle);
     if (handle_is_available)
     {
         JitterUser new_user = new JitterUser { RealUser = app_user, Handle = new_handle };
         bool is_added = true;
         try
         {
             JitterUser added_user = _context.JitterUsers.Add(new_user);
             _context.SaveChanges();
         }
         catch (Exception)
         {
             is_added = false;
         }
         return is_added;
     }
     else
     {
         return false;
     }
 }
Esempio n. 12
0
        public void JitterRepositoryEnsureICanCreateAJot()
        {
            // Arrange
            DateTime base_time = DateTime.Now;
            // This is our database
            List<Jot> expected_jots = new List<Jot>();

            ConnectMocksToDataStore(expected_jots);
            JitterUser jitter_user1 = new JitterUser { Handle = "lukeskywalker1" };
            string content = "Hello Jitter World!";
            mock_jot_set.Setup(j => j.Add(It.IsAny<Jot>())).Callback((Jot s) => expected_jots.Add(s));

            // Act
            bool successful = repository.CreateJot(jitter_user1, content);

            // Assert
            // Should this return true?
            Assert.AreEqual(1, repository.GetAllJots().Count);

            // Assert.IsTrue(successful);
        }
Esempio n. 13
0
 public void JitterUserEnsureICanCreateInstance()
 {
     JitterUser a_user = new JitterUser();
     Assert.IsNotNull(a_user);
 }
 public List<Jot> GetUserJots(JitterUser user)
 {
     // user may be null b/c of Line 75 in JitterController
     if (user != null)
     {
         var query = from u in _context.JitterUsers where u.JitterUserId == user.JitterUserId select u;
         JitterUser found_user = query.SingleOrDefault<JitterUser>();
         if (found_user == null)
         {
             return new List<Jot>();
         }
         return found_user.Jots;
     } else
     {
         return new List<Jot>();
     }
 }
 public List<Jot> GetUserJots(JitterUser user)
 {
     var query = from u in _context.JitterUsers where u.JitterUserId == user.JitterUserId select u;
     JitterUser found_user = query.Single<JitterUser>();
     return found_user.Jots;
 }
 public void JitterUserEnsureICanCreateInstance()
 {
     JitterUser user = new JitterUser();
     Assert.IsInstanceOfType(user, typeof(JitterUser));
 }