示例#1
0
        public string CheckRegistration(User newUser)
        {
            if (string.IsNullOrEmpty(newUser.UserName) || string.IsNullOrEmpty(newUser.Password))
            {
                return(NullCred);
            }
            else if (newUser.UserName.Length > UserNameMaxLength)
            {
                return(UserNameTooLong);
            }
            else
            {
                User userAlreadyExists = _usersAccessor.FindUser(newUser.UserName);

                if (userAlreadyExists != null)
                {
                    return(UserAlreadyExists);
                }
                else
                {
                    _usersAccessor.InsertUser(newUser);

                    Event defaultEvent = new Event()
                    {
                        DateCreated = DateTime.Now,
                        Description = "You created this account.",
                        UserName    = newUser.UserName
                    };

                    _eventsAccessor.InsertEvent(defaultEvent);

                    return(SuccessfulRegistration);
                }
            }
        }
        public void InsertEvent_WithGivenEvent_ShouldBeAbleToFindEvent()
        {
            //Arrange
            Event eventToBeInserted = new Event()
            {
                DateCreated = new DateTime(2020, 12, 6),
                Description = "I've used the bathroom",
                UserName    = "******"
            };

            //Act
            _eventsAccessor.InsertEvent(eventToBeInserted);
            Event foundEvent = this.FindEventWithDescription(eventToBeInserted.Description);

            //Assert
            Assert.That(foundEvent.DateCreated, Is.EqualTo(eventToBeInserted.DateCreated));
            Assert.That(foundEvent.Description, Is.EqualTo(eventToBeInserted.Description));
            Assert.That(foundEvent.UserName, Is.EqualTo(eventToBeInserted.UserName));

            //TearDown
            _eventsAccessor.DeleteEvent(foundEvent);
        }
示例#3
0
 public void AddEvent(Event evnt)
 {
     _eventsAccessor.InsertEvent(evnt);
 }