コード例 #1
0
ファイル: UserManager.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Create a user event with notes
        /// </summary>
        /// <param name="userName">user name to record event for</param>
        /// <param name="eventType">Event type based upon UserEventTypeCode</param>
        /// <param name="notes">notes</param>
        /// <param name="reference">Reference</param>
        public void RecordUserEvent(string userName, UserEventTypesEnum eventType, string notes = null, string reference = null)
        {
            MembershipUser user = null;

            if (string.IsNullOrEmpty(userName) == false)
            {
                user = Membership.GetUser(userName);
            }

            //Empty used for bad username case
            Guid? foundUserId = user != null ? (Guid?)user.ProviderUserKey : Guid.Empty;

            var userEvent = new UserEvent
            {
                UserId = foundUserId,
                UserEventType = new UserEventType { Code = eventType.GetCode() },
                Reference = reference ?? userName,
                Notes = notes,
            };

            userEventDao.Create(userEvent);
        }
コード例 #2
0
ファイル: UserManagerTests.cs プロジェクト: ognjenm/egle
            public void ModifyUserStatusCreatesRelatedEventType(UserStatusEnum userStatus, UserEventTypesEnum expectedUserEvent)
            {
                // Arrange
                var userId = new Guid("00000000-0000-0000-0000-000000000001");

                string expectedUserEventCode = expectedUserEvent.GetCode();

                var mockUserEventDao = MockRepository.GenerateMock<IUserEventDao>();
                mockUserEventDao.Expect(u => u.Create(Arg<UserEvent>.Matches(ue => ue.UserEventType.Code == expectedUserEventCode)));

                var userManager = new UserManager();
                userManager.UserEventDao = mockUserEventDao;
                userManager.UserExtensionDao = MockRepository.GenerateStub<IUserExtensionDao>();

                // Act
                userManager.ModifyUserSatus(userId, userStatus, "notes");

                // Assert
                mockUserEventDao.VerifyAllExpectations();
            }