示例#1
0
        public static UserList Create(string userEmail, string location, string name,
                                      string description, string imageUrl, string eventType, DateTime startTime, DateTime endTime)
        {
            EnsureArg.IsNotNullOrEmpty(userEmail);
            EnsureArg.IsNotNullOrEmpty(location);
            EnsureArg.IsNotNullOrEmpty(name);
            EnsureArg.IsNotNullOrEmpty(description);
            EnsureArg.IsNotNullOrEmpty(imageUrl);
            EnsureArg.IsNotNullOrEmpty(eventType);
            EnsureArg.IsDateTime(startTime);
            EnsureArg.IsDateTime(endTime);

            var instance = new UserList
            {
                Id          = Guid.NewGuid(),
                UserEmail   = userEmail,
                Location    = location,
                Name        = name,
                Description = description,
                ImageUrl    = imageUrl,
                EventType   = eventType,
                StartTime   = startTime,
                EndTime     = endTime
            };

            return(instance);
        }
 public void IsDateTime_WhenNotTypeOf_ThrowsArgumentException() => AssertIsOfTypeScenario(
     typeof(DateTime), typeof(int),
     () => Ensure.Type.IsDateTime(typeof(int), ParamName),
     () => Ensure.Type.IsDateTime(42, ParamName),
     () => EnsureArg.IsDateTime(typeof(int), ParamName),
     () => EnsureArg.IsDateTime(42, ParamName),
     () => Ensure.ThatType(typeof(int), ParamName).IsDateTime(),
     () => Ensure.ThatTypeFor(42, ParamName).IsDateTime());
示例#3
0
 public AddPerson(PersonDTO personDTO)
 {
     EnsureArg.IsNotNull(personDTO);
     EnsureArg.IsNotNullOrEmpty(personDTO.FirstName);
     EnsureArg.IsNotNullOrEmpty(personDTO.SurName);
     EnsureArg.IsNotNullOrEmpty(personDTO.PhoneNumber);
     EnsureArg.IsDateTime(personDTO.DateOfBirth);
     PersonDTO = personDTO;
 }
示例#4
0
        public void IsDateTime_WhenIsCorrectType_It_should_not_throw()
        {
            var value = DateTime.Now;

            ShouldNotThrow(
                () => Ensure.ThatTypeFor(value, ParamName).IsDateTime(),
                () => EnsureArg.IsDateTime(typeof(DateTime), ParamName),
                () => EnsureArg.IsDateTime(value, ParamName));
        }
示例#5
0
 public EditPerson(PersonDTO person)
 {
     EnsureArg.IsNotNull(person);
     EnsureArg.IsTrue(person.PersonId > 0);
     EnsureArg.IsNotNullOrEmpty(person.FirstName);
     EnsureArg.IsNotNullOrEmpty(person.SurName);
     EnsureArg.IsNotNullOrEmpty(person.PhoneNumber);
     EnsureArg.IsDateTime(person.DateOfBirth);
     PersonDTO = person;
 }
示例#6
0
        public void IsDateTime_WhenIsCorrectType_It_should_not_throw()
        {
            var value = DateTime.Now;

            var returnedValue = Ensure.ThatTypeFor(value, ParamName).IsDateTime();

            AssertReturnedAsExpected(returnedValue, typeof(DateTime));

            Action a = () => EnsureArg.IsDateTime(typeof(DateTime), ParamName);

            a.ShouldNotThrow();

            Action b = () => EnsureArg.IsDateTime(value, ParamName);

            b.ShouldNotThrow();
        }
示例#7
0
        public static Event Create(string location, string facebookId, string name, string description, DateTime startTime, DateTime endTime, string imageUrl)
        {
            EnsureArg.IsNotNullOrEmpty(location);
            EnsureArg.IsNotNullOrEmpty(facebookId);
            EnsureArg.IsNotNullOrEmpty(name);
            EnsureArg.IsNotNullOrEmpty(description);
            EnsureArg.IsDateTime(startTime);
            EnsureArg.IsDateTime(endTime);
            EnsureArg.IsNotNullOrEmpty(imageUrl);

            var instance = new Event
            {
                Id = Guid.NewGuid()
            };

            instance.Update(location, facebookId, name, description, startTime, endTime, imageUrl);

            return(instance);
        }
示例#8
0
        public void Update(string location, string facebookId, string name, string description, DateTime startTime, DateTime endTime, string imageUrl)
        {
            EnsureArg.IsNotNullOrEmpty(location);
            EnsureArg.IsNotNullOrEmpty(facebookId);
            EnsureArg.IsNotNullOrEmpty(name);
            EnsureArg.IsNotNullOrEmpty(description);
            EnsureArg.IsDateTime(startTime);
            EnsureArg.IsDateTime(endTime);
            EnsureArg.IsNotNullOrEmpty(imageUrl);

            this.Location    = location;
            this.FacebookId  = facebookId;
            this.Name        = name;
            this.Description = description;
            this.StartTime   = startTime;
            this.EndTime     = endTime;
            this.StartTime   = startTime;
            this.EndTime     = endTime;
            this.ImageUrl    = imageUrl;
        }
示例#9
0
        public void Update(string userEmail, string location, string name,
                           string description, string imageUrl, string eventType, DateTime startTime, DateTime endTime)
        {
            EnsureArg.IsNotNullOrEmpty(userEmail);
            EnsureArg.IsNotNullOrEmpty(location);
            EnsureArg.IsNotNullOrEmpty(name);
            EnsureArg.IsNotNullOrEmpty(description);
            EnsureArg.IsNotNullOrEmpty(imageUrl);
            EnsureArg.IsNotNullOrEmpty(eventType);
            EnsureArg.IsDateTime(startTime);
            EnsureArg.IsDateTime(endTime);

            this.UserEmail   = userEmail;
            this.Location    = location;
            this.Name        = name;
            this.Description = description;
            this.ImageUrl    = imageUrl;
            this.EndTime     = endTime;
            this.StartTime   = startTime;
            this.EndTime     = endTime;
        }