Inheritance: System.Entity
示例#1
0
        public Presentation(UserProfile user, string title, string description, PresentationLevel level, PresentationCategory category)
        {
            User = user;
            UserId = user.Id;
            Title = title;
            Description = description;
            Level = level;
            Category = category;
            Track = "None";
            Slot = "None";

            Status = PresentationStatus.Pending;

            Raise(new PresentationCreated {PresentationId = Id});
        }
        public void Sessions_Return_With_A_Day_property_from_Model()
        {
            //arrange
            var repository = MockRepository.GenerateMock<IRepository>();
            var userProfile = new UserProfile("test", "test", "test"){Id = 1};
            repository.Stub(x => x.Find<UserProfile>()).Return(
                new List<UserProfile> {userProfile}.AsQueryable()
                );

            repository.Stub(x => x.Find<Session>()).Return(new List<Session>
                                                                    {
                                                                        new Session
                                                                        {
                                                                            Status = SessionStatus.Accepted,
                                                                            Category = SessionCategory.Developers,
                                                                            User = userProfile,
                                                                            Title = "Test",
                                                                            Description = "test",
                                                                            Level = SessionLevel.Beginner,
                                                                            Day = 1
                                                                        }
                                                                    }.AsQueryable());
            var currentUserService = MockRepository.GenerateMock<ICurrentUserService>();
            var membershipService = MockRepository.GenerateMock<IMembershipService>();
            membershipService.Stub(x => x.IsUserInRole("test", "Admin")).Return(true);

            AdminController target = new AdminController(repository, currentUserService, membershipService);
            //act
            ActionResult result = target.Sessions();

            //assert
            var model = result.AssertViewRendered().ViewData.Model;
            Assert.IsInstanceOfType(model,typeof(AdminSessionsModel));
            Assert.IsNotNull(((AdminSessionsModel)model).Sessions);
            var session = ((AdminSessionsModel) model).Sessions.FirstOrDefault();
            Assert.IsNotNull(session);
            Assert.AreEqual(1,session.Day);
        }
 private MembershipUser Map(UserProfile user)
 {
     return new MembershipUser(
         Name, // Provider name
         user.Email, // Username
         user.Id, // providerUserKey
         user.Email, // Email
         string.Empty, // passwordQuestion
         string.Empty, // Comment
         true, // isApproved
         false, // isLockedOut
         user.CreationDate, // creationDate
         DateTime.MinValue, // lastLoginDate
         DateTime.MinValue, // lastActivityDate
         user.CreationDate, // lastPasswordChangedDate
         DateTime.MinValue); // lastLockoutDate
 }
        private UserProfile[] GetUsers()
        {
            var users = _repository.Find<UserProfile>().ToArray();

            if (users.Length == 0)
            {
                var user = new UserProfile("*****@*****.**", "dev", "Developer");
                _repository.Save(user);
                users = new[] {user};
            }

            return users;
        }
 public bool Is(UserProfile user)
 {
     return user != null && Is(user.Email);
 }
 public bool Is(UserProfile user)
 {
     return Is(user.Email);
 }