public void Can_save_and_load_poll() { var poll = new Poll { Name = "Name 1", SystemKeyword = "SystemKeyword 1", Published = true, ShowOnHomePage = true, DisplayOrder = 1, StartDateUtc = new DateTime(2010, 01, 01), EndDateUtc = new DateTime(2010, 01, 02), Language = new Language() { Name = "English", LanguageCulture = "en-Us", } }; var fromDb = SaveAndLoadEntity(poll); fromDb.ShouldNotBeNull(); fromDb.Name.ShouldEqual("Name 1"); fromDb.SystemKeyword.ShouldEqual("SystemKeyword 1"); fromDb.Published.ShouldEqual(true); fromDb.ShowOnHomePage.ShouldEqual(true); fromDb.DisplayOrder.ShouldEqual(1); fromDb.StartDateUtc.ShouldEqual(new DateTime(2010, 01, 01)); fromDb.EndDateUtc.ShouldEqual(new DateTime(2010, 01, 02)); fromDb.Language.ShouldNotBeNull(); fromDb.Language.Name.ShouldEqual("English"); }
public void Can_save_and_load_poll_with_answers() { var poll = new Poll { Name = "Name 1", SystemKeyword = "SystemKeyword 1", Published = true, ShowOnHomePage = true, DisplayOrder = 1, StartDateUtc = new DateTime(2010, 01, 01), EndDateUtc = new DateTime(2010, 01, 02), Language = new Language() { Name = "English", LanguageCulture = "en-Us", } }; poll.PollAnswers.Add ( new PollAnswer { Name = "Answer 1", NumberOfVotes = 1, DisplayOrder = 2, } ); var fromDb = SaveAndLoadEntity(poll); fromDb.ShouldNotBeNull(); fromDb.PollAnswers.ShouldNotBeNull(); (fromDb.PollAnswers.Count == 1).ShouldBeTrue(); fromDb.PollAnswers.First().Name.ShouldEqual("Answer 1"); fromDb.PollAnswers.First().NumberOfVotes.ShouldEqual(1); fromDb.PollAnswers.First().DisplayOrder.ShouldEqual(2); }
/// <summary> /// Deletes a poll /// </summary> /// <param name="poll">The poll</param> public virtual void DeletePoll(Poll poll) { if (poll == null) throw new ArgumentNullException("poll"); _pollRepository.Delete(poll); //event notification _eventPublisher.EntityDeleted(poll); }
public static Poll ToEntity(this PollModel model, Poll destination) { return Mapper.Map(model, destination); }
public void Can_save_and_load_poll_with_answer_and_votingrecord() { var poll = new Poll { Name = "Name 1", SystemKeyword = "SystemKeyword 1", Published = true, ShowOnHomePage = true, DisplayOrder = 1, StartDateUtc = new DateTime(2010, 01, 01), EndDateUtc = new DateTime(2010, 01, 02), Language = new Language() { Name = "English", LanguageCulture = "en-Us", } }; poll.PollAnswers.Add ( new PollAnswer { Name = "Answer 1", NumberOfVotes = 1, DisplayOrder = 2, } ); poll.PollAnswers.First().PollVotingRecords.Add ( new PollVotingRecord { Customer = GetTestCustomer(), CreatedOnUtc = DateTime.UtcNow } ); var fromDb = SaveAndLoadEntity(poll); fromDb.ShouldNotBeNull(); fromDb.PollAnswers.ShouldNotBeNull(); (fromDb.PollAnswers.Count == 1).ShouldBeTrue(); fromDb.PollAnswers.First().PollVotingRecords.ShouldNotBeNull(); (fromDb.PollAnswers.First().PollVotingRecords.Count == 1).ShouldBeTrue(); }