public void ValidateValidatesChildren()
 {
     var validated = false;
     var project = new ProjectStub
                       {
                           Name = "Project",
                           OnValidate = vl => validated = true
                       };
     var server = new Server("Server", project);
     var validationStub = new ValidationLogStub();
     server.Validate(validationStub);
     Assert.IsTrue(validated);
 }
 public void ValidateValidatesName()
 {
     var validated = false;
     var server = new Server();
     var validationStub = new ValidationLogStub
                              {
                                  OnAddErrorMessage = (m, a) =>
                                                          {
                                                              Assert.AreEqual("The Server has no name specified.", m);
                                                              Assert.AreEqual(0, a.Length);
                                                              validated = true;
                                                          }
                              };
     server.Validate(validationStub);
     Assert.IsTrue(validated);
 }
Beispiel #3
0
 public void ValidateReturnsWarningIfNoName()
 {
     var warningAdded = false;
     var channel = new Wcf();
     var validator = new ValidationLogStub
                         {
                             OnAddWarningMessage = (m, a) =>
                                                       {
                                                           Assert.AreEqual("Channel does not have a name", m);
                                                           CollectionAssert.IsEmpty(a);
                                                           warningAdded = true;
                                                       }
                         };
     channel.Validate(validator);
     Assert.IsTrue(warningAdded);
 }
 public void ValidateDetectsMissingPeriod()
 {
     var errorAdded = false;
     var trigger = new RollUp();
     var validation = new ValidationLogStub
                          {
                              OnAddErrorMessage = (m, a) =>
                                                      {
                                                          Assert.AreEqual(
                                                              "No period set - trigger will not fire",
                                                              m);
                                                          CollectionAssert.IsEmpty(a);
                                                          errorAdded = true;
                                                      }
                          };
     trigger.Validate(validation);
     Assert.IsTrue(errorAdded);
 }
 public void ValidateDetectsDuplicateChildItems()
 {
     var errorAdded = false;
     var project1 = new Project("Project");
     var project2 = new Project("Project");
     var project3 = new Project("OtherProject");
     var queue = new Queue("QueueName", project1, project2, project3);
     var validationStub = new ValidationLogStub
                              {
                                  OnAddErrorMessage = (m, a) =>
                                                          {
                                                              Assert.AreEqual(
                                                                  "Duplicate {1} name detected: '{0}'", m);
                                                              CollectionAssert.AreEqual(
                                                                  new[] { "Project", "child" },
                                                                  a);
                                                              errorAdded = true;
                                                          }
                              };
     queue.Validate(validationStub);
     Assert.IsTrue(errorAdded);
 }
 public void ProjectNameIsCheckedInValidation()
 {
     var project = new Project();
     var verified = false;
     var validationStub = new ValidationLogStub
                              {
                                  OnAddErrorMessage = (m, a) =>
                                                          {
                                                              Assert.AreEqual("The {0} has no name specified.", m);
                                                              Assert.AreEqual("Project", a[0]);
                                                              verified = true;
                                                          }
                              };
     project.Validate(validationStub);
     Assert.IsTrue(verified);
 }
 public void ValidateDetectsDuplicateChildItems()
 {
     var errorAdded = false;
     var queue1 = new Queue("Queue");
     var queue2 = new Queue("Queue");
     var queue3 = new Queue("OtherQueue");
     var server = new Server("Server", queue1, queue2, queue3);
     var validationStub = new ValidationLogStub
                              {
                                  OnAddErrorMessage = (m, a) =>
                                                          {
                                                              Assert.AreEqual(
                                                                  "Duplicate {1} name detected: '{0}'", m);
                                                              CollectionAssert.AreEqual(
                                                                  new[] { "Queue", "child" },
                                                                  a);
                                                              errorAdded = true;
                                                          }
                              };
     server.Validate(validationStub);
     Assert.IsTrue(errorAdded);
 }
 public void ValidateDetectsDuplicateProjects()
 {
     var errorAdded = false;
     var project1 = new Project("Project");
     var project2 = new Project("Project");
     var childQueue = new Queue("Test", project2);
     var project3 = new Project("OtherProject");
     var server = new Server("Server", project1, childQueue, project3);
     var validationStub = new ValidationLogStub
                              {
                                  OnAddErrorMessage = (m, a) =>
                                                          {
                                                              Assert.AreEqual(
                                                                  "Duplicate {1} name detected: '{0}'", m);
                                                              CollectionAssert.AreEqual(
                                                                  new[] { "Project", "project" },
                                                                  a);
                                                              errorAdded = true;
                                                          }
                              };
     server.Validate(validationStub);
     Assert.IsTrue(errorAdded);
 }