public void Can_delete_profile()
        {
            #region Arrange
            var profile = new ProfileModel { LoginName = "delete test", Email = "*****@*****.**", IsActive = true };
            int id = -1;
            DataAccess.InTransaction(session =>
            {
                id = (int)session.Save(profile);
            });
            #endregion

            #region Act
            var profileDto = ProfileModelDto.Map(profile);
            profileDto.ID = id;
            bool deleteOk = new ProfileService().DeleteProfile(profileDto);

            IList<ProfileModel> profiles = null;

            DataAccess.InTransaction(session =>
            {
                profiles = session.CreateCriteria(typeof(ProfileModel)).List<ProfileModel>();
            });

            #endregion

            #region Assert
            Assert.That(deleteOk, Is.True);
            Assert.That(profiles.Count, Is.EqualTo(1));
            #endregion
        }
        public void SetUp()
        {
            //Initializaing Mappings
            DtoMappings.Initialize();

            //Initializing Data
            TestShoutBoxMessage = new ShoutBoxMessageModel{Author = "test",Message = "test",ShoutBoxId = 1,TimePosted = new DateTime(2010,10,10,10,10,10)};
            TestShoutBoxMessage1 = new ShoutBoxMessageModel { Author = "test", Message = "testLatest", ShoutBoxId = 1, TimePosted = new DateTime(2011, 10, 10, 10, 10, 10) };
            TestQuestionAnswer = new TestQuestionAnswer {Correct = true,NumberSelected = 0, Text = "test"};
            TestQuestion = new TestQuestionModel
                                { QuestionText = "test question",QuestionLabel ="test", Answers = new List<TestQuestionAnswer>
                                                                                { TestQuestionAnswer } };
            TestTestType = new TestTypeModel { TypeName = "test" };
            TestPofile = new ProfileModel { LoginName = "test", Email = "*****@*****.**", IsActive = true };
            TestTest = new TestModel
                            { Author = TestPofile, CreationDate = new DateTime(2010, 1, 1), Name = "test", TestType = TestTestType };
            LatestTest = new TestModel
                              { Author = TestPofile, CreationDate = new DateTime(2011, 1, 1), Name = "test", TestType = TestTestType };
            TestCourseType = new CourseTypeModel { TypeName = "Fizyka" };
            TestCourseType1 = new CourseTypeModel { TypeName = "Matematyka" };
            TestGroupType = new GroupTypeModel { TypeName = "test" };
            TestGroupType1 = new GroupTypeModel { TypeName = "test1" };
            TestGroup = new GroupModel { GroupType = TestGroupType, GroupName = "test" };
            TestForum = new ForumModel { Author = "test", Name = "test" };
            TestShoutBox = new ShoutboxModel();
            TestShoutBox.Messages.Add(TestShoutBoxMessage);
            TestShoutBox.Messages.Add(TestShoutBoxMessage1);
            TestSurvey = new SurveyModel
                              { SurveyText = "Smiga chodzi fruwa ?", DateCreated = new DateTime(2010, 1, 1) };
            TestLatestSurvey = new SurveyModel
                                    { SurveyText = "Smiga chodzi fruwa ?", DateCreated = new DateTime(2011, 1, 1) };

            TestCourse2 = new CourseModel
                               {
                CourseType = TestCourseType1,
                ShoutBox = TestShoutBox,
                Forum = TestForum,
                Group = TestGroup,
                CreationDate = DateTime.Now,
                Description = "test1",
                Logo = "/test1.jpg",
                Name = "test1",
                Password ="******"

            };

            TestCourse3 = new CourseModel
                               {
                CourseType = TestCourseType1,
                ShoutBox = TestShoutBox,
                Forum = TestForum,
                Group = TestGroup,
                CreationDate = DateTime.Now,
                Description = "test1",
                Logo = "/test1.jpg",
                Name = "test1",
                Password = null

            };
            TestContentType = new ContentTypeModel {TypeName = "test"};
            TestContent = new ContentModel
                               {
                                   ContentUrl = "test",
                                   CreationDate = DateTime.Now,
                                   DownloadNumber = 0,
                                   Name="test",
                                   Text = "test",
                                   Type = TestContentType
                               };
            TestJournalMark = new JournalMarkModel { Name = "Zaliczenie", Value = "5" };
            TestJournal = new JournalModel
                               { Course = TestCourse3,Marks = new List<JournalMarkModel>
                                                                                     { TestJournalMark }, Name = "test journal" };

            FileModel = new FileModel {FileName = "test", Address = "test"};
            SectionModel = new SectionModel {IconName = "test", Text = "test", Title = "tset"};

            LearningMaterialModel = new LearningMaterialModel
                                        {
                                            Level = 1,
                                            CreationDate = DateTime.Now,
                                            Description = "test",
                                            Goals = "test",
                                            Summary = "test",
                                            UpdateDate = DateTime.Now,
                                            VersionNumber = "111",
                                            Tests = new List<TestModel> {TestTest},
                                            Files = new List<FileModel> {FileModel},
                                            Sections = new List<SectionModel> {SectionModel}
                                        };
            TestCourse1 = new CourseModel
            {
                CourseType = TestCourseType,
                ShoutBox = TestShoutBox,
                Forum = TestForum,
                Group = TestGroup,
                CreationDate = DateTime.Now,
                Description = "test",
                Logo = "/test.jpg",
                Name = "test",
                Password = "******",
                LearningMaterials = new List<LearningMaterialModel> { LearningMaterialModel }
            };

            using (var session = DataAccess.OpenSession())
            {
                session.Save(TestPofile);
                session.Save(TestShoutBoxMessage);
                session.Save(TestShoutBoxMessage1);
                session.Save(TestCourseType);
                session.Save(TestGroupType);
                session.Save(TestGroupType1);
                session.Save(TestGroup);
                session.Save(TestForum);
                session.Save(TestShoutBox);
                session.Save(TestCourseType1);
                session.Save(TestSurvey);
                session.Save(TestLatestSurvey);
                session.Save(TestTestType);
                session.Save(TestTest);
                session.Save(LatestTest);
                session.Save(TestCourse1);
                session.Save(TestCourse2);
                session.Save(TestQuestionAnswer);
                session.Save(TestQuestion);
                session.Save(TestCourse3);
                session.Save(TestJournalMark);
                session.Save(TestJournal);
                session.Save(TestContentType);
                session.Save(TestContent);
                session.Save(FileModel);
                session.Save(SectionModel);
                session.Save(LearningMaterialModel);
                session.Flush();
            }
        }
        public void Can_get_profile_by_username()
        {
            #region Arrange
            var profile = new ProfileModel { LoginName = "test profile", Email = "*****@*****.**", IsActive = true };
            #endregion

            #region Act

            using (var session = DataAccess.OpenSession())
            {
                session.Save(profile);
            }
            var returnedProfile = new ProfileService().GetByName("test profile");
            #endregion

            #region Assert
            Assert.That(returnedProfile,Is.Not.Null);
            Assert.That(returnedProfile.LoginName, Is.EqualTo("test profile"));
            #endregion
        }
        public void Can_get_all_profiles()
        {
            #region Arrange
            var profile = new ProfileModel { LoginName = "test1", Email = "*****@*****.**", IsActive = true };
            DataAccess.InTransaction(session => session.Save(profile));
            #endregion

            #region Act

            var profiles = new ProfileService().GetAllProfiles();

            #endregion

            #region Assert
            Assert.That(profiles.First(),Is.InstanceOf(typeof(ProfileModelDto)));
            Assert.That(profiles.Count,Is.EqualTo(2));
            #endregion
        }