public void Can_add_new_shoutbox_message() { #region Arrange var msg = new ShoutBoxMessageModelDto { Author = "test", Message = "test", TimePosted = DateTime.Now, ShoutBoxId = 1 }; #endregion #region Act int?id = new CourseService().AddShoutBoxMessage(msg); using (var session = DataAccess.OpenSession()) { var shoutbox = session.Get <ShoutboxModel>(1); #endregion #region Assert Assert.IsNotNull(id); Assert.IsNotNull(shoutbox); Assert.That(shoutbox.Messages.First().Message, Is.EqualTo("test")); #endregion } }
public void Can_add_new_shoutbox_message() { #region Arrange var msg = new ShoutBoxMessageModelDto {Author = "test", Message = "test", TimePosted = DateTime.Now,ShoutBoxId = 1}; #endregion #region Act int? id = new CourseService().AddShoutBoxMessage(msg); using (var session = DataAccess.OpenSession()) { var shoutbox = session.Get<ShoutboxModel>(1); #endregion #region Assert Assert.IsNotNull(id); Assert.IsNotNull(shoutbox); Assert.That(shoutbox.Messages.First().Message, Is.EqualTo("test")); #endregion } }
public int?AddShoutBoxMessage(ShoutBoxMessageModelDto msg) { try { return(new Repository <ShoutBoxMessageModel>().Add(ShoutBoxMessageModelDto.UnMap(msg))); } catch (Exception ex) { Logger.Error("Error : CourseService.AddShoutBoxMessage - {0}", ex.Message); return(null); } }
public int? AddShoutBoxMessage(ShoutBoxMessageModelDto msg) { try { return new Repository<ShoutBoxMessageModel>().Add(ShoutBoxMessageModelDto.UnMap(msg)); } catch (Exception ex) { Logger.Error("Error : CourseService.AddShoutBoxMessage - {0}", ex.Message); return null; } }
public BaseTest() { SampleMessage = new ShoutBoxMessageModelDto { Author = "test", Message = "test", ShoutBoxId = 1, TimePosted = DateTime.Now }; SampleMessages = new [] { new ShoutBoxMessageModelDto { Author = "test", Message = "test", TimePosted = DateTime.Now } }; }
public IList <ShoutBoxMessageModelDto> GetLatestShoutBoxMessages(int shoutBoxId, int numberOfMessages) { try { List <ShoutBoxMessageModel> msgs; using (var session = DataAccess.OpenSession()) { msgs = session.Get <ShoutboxModel>(shoutBoxId).Messages.OrderByDescending(c => c.TimePosted).Take(numberOfMessages).ToList(); } return(ShoutBoxMessageModelDto.Map(msgs)); } catch (Exception ex) { Logger.Error("Error : CourseService.GetLatestShoutBoxMessages - {0}", ex.Message); return(new List <ShoutBoxMessageModelDto>()); } }
public BaseTest() { SampleMessage = new ShoutBoxMessageModelDto { Author="test", Message ="test", ShoutBoxId = 1, TimePosted = DateTime.Now }; SampleMessages = new [] {new ShoutBoxMessageModelDto{Author = "test",Message = "test",TimePosted = DateTime.Now} }; }