コード例 #1
0
 public void Create_Planet_With_Title_That_Does_Not_Already_Exists()
 {
     using (var context = GetContextWithData())
     {
         var validator = new CreatePlanetCommandValidator(context);
         var result    = validator.TestValidate(new CreatePlanetCommand
         {
             Id   = new Guid(),
             Name = Name
         });
         result.ShouldNotHaveValidationErrorFor(x => x.Name);
     }
 }
コード例 #2
0
        public void Create_Planet_With_Name_That_Already_Exists_Throws_Exception()
        {
            using (var context = GetContextWithData())
            {
                var validator = new CreatePlanetCommandValidator(context);
                var name      = context.Planets.FirstOrDefault()?.Name;

                if (name == null)
                {
                    return;
                }

                var result = validator.TestValidate(new CreatePlanetCommand
                {
                    Id   = new Guid(),
                    Name = name
                });
                result.ShouldHaveValidationErrorFor(x => x);
            }
        }