public void Post(Jot new_jot) { string user_id = User.Identity.GetUserId(); JitterUser me = Repo.GetAllUsers().Where(u => u.RealUser.Id == user_id).SingleOrDefault(); if (me != null) { Repo.CreateJot(me, new_jot.Content); } }
public void JotEnsureICanUseObjectInitializerSyntax() { // Arrange DateTime expected_time = DateTime.Now; // Act Jot a_jot = new Jot { JotId = 1, Content = "My Content", Date = expected_time, Author = null, Picture = "https://google.com" }; // Assert Assert.AreEqual(1, a_jot.JotId); Assert.AreEqual("My Content", a_jot.Content); Assert.AreEqual(expected_time, a_jot.Date); Assert.AreEqual(null, a_jot.Author); Assert.AreEqual("https://google.com", a_jot.Picture); }
public void JotEnsureJotHasAllTheThings() { // Arrange Jot a_jot = new Jot(); // Act DateTime expected_time = DateTime.Now; a_jot.JotId = 1; a_jot.Content = "My Content"; a_jot.Date = expected_time; a_jot.Author = null; // Will need to define this later a_jot.Picture = "https://google.com"; // Assert Assert.AreEqual(1, a_jot.JotId); Assert.AreEqual("My Content", a_jot.Content); Assert.AreEqual(expected_time, a_jot.Date); Assert.AreEqual(null, a_jot.Author); Assert.AreEqual("https://google.com", a_jot.Picture); }
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 void JotEnsureICanCreateInstance() { Jot a_jot = new Jot(); Assert.IsNotNull(a_jot); }