Пример #1
0
        public void TestVRPInstances()
        {
            var vrp             = new VehicleRoutingProblem();
            var providers       = ProblemInstanceManager.GetProviders(vrp);
            var failedInstances = new StringBuilder();

            Assert.IsTrue(providers.Any(), "No providers could be found.");

            foreach (var provider in providers)
            {
                IEnumerable <IDataDescriptor> instances = ((dynamic)provider).GetDataDescriptors();
                Assert.IsTrue(instances.Any(), string.Format("No instances could be found in {0}.", provider.Name));

                foreach (var instance in instances)
                {
                    try {
                        // throws InvalidOperationException if zero or more than one interpreter is found
                        ((dynamic)vrp).Load(((dynamic)provider).LoadData(instance));
                    } catch (Exception exc) {
                        failedInstances.AppendLine(instance.Name + ": " + exc.Message);
                    }
                }
            }

            Assert.IsTrue(failedInstances.Length == 0, "Following instances failed: " + Environment.NewLine + failedInstances);
        }
Пример #2
0
 protected override void OnContentChanged()
 {
     base.OnContentChanged();
     if (Content == null)
     {
         problemInstanceProviders = null;
         problemInstanceProviderComboBox.DataSource    = null;
         problemInstanceSplitContainer.Panel1Collapsed = true;
     }
     else
     {
         var consumer = Content as IProblemInstanceConsumer;
         if (consumer != null)
         {
             problemInstanceProviders = ProblemInstanceManager.GetProviders(Content);
             bool expand = problemInstanceProviders.Any();
             if (expand)
             {
                 problemInstanceProviderComboBox.DisplayMember = "Name";
                 problemInstanceProviderComboBox.DataSource    = ProblemInstanceProviders.OrderBy(x => x.Name).ToList();
             }
             problemInstanceSplitContainer.Panel1Collapsed = !expand;
         }
         else
         {
             problemInstanceSplitContainer.Panel1Collapsed = true;
         }
     }
     SetEnabledStateOfControls();
 }