Пример #1
0
        public void BuildTreeWithDepth1()
        {
            TreeFactory factory    = new TreeFactory();
            var         treeSystem = factory.Create(1);

            treeSystem.Tree.Should().NotBeNull();
            treeSystem.Tree.Should().BeOfType(typeof(Gate));
            treeSystem.Tree.As <Gate>().LeftNode.Should().BeOfType(typeof(Container));
            treeSystem.Tree.As <Gate>().RightNode.Should().BeOfType(typeof(Container));
            treeSystem.Containers.Count.Should().Be(2);
            treeSystem.Containers[0].ContainerNumber.Should().Be(0);
            treeSystem.Containers[1].ContainerNumber.Should().Be(1);
        }
Пример #2
0
 private static Measurement.MakePerfTest MakePerfTestEnumerationMaker <TreeType, EntryType>(TreeFactory <TreeType> treeFactory, int count, TestBase.TreeKind treeKind, TestBase.EnumKind enumKind, bool forward)
 {
     return(delegate()
     {
         return new PerfTestEnumeration <TreeType, EntryType>(delegate(int _count) { return treeFactory.Create(_count); }, count, treeKind, enumKind, forward);
     });
 }
Пример #3
0
        private void SelectFactory(string line, NetFactory netFactory, BuildingFactory buildingFactory, PropFactory propFactory,
                                   ResourceFactory resourceFactory, TreeFactory treeFactory, WaterFactory waterFactory)
        {
            if (!line.IsNullOrWhiteSpace())
            {
                List <string> arguments = line.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                float[]       points;
                float         angle;
                switch (arguments[0])
                {
                case "Resource":
                    points = ReturnFloatsFromArg(arguments);
                    NaturalResourceManager.Resource resource = (NaturalResourceManager.Resource)Enum
                                                               .Parse(typeof(NaturalResourceManager.Resource), arguments[1], true);
                    resourceFactory.CreateResource(new Vector2(points[0], points[1]), resource);
                    timesResourceUsed++;
                    break;

                case "Water":
                    points = ReturnFloatsFromArg(arguments);
                    var flowInOut = arguments[3].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(x => uint.Parse(x, CultureInfo.InvariantCulture))
                                    .ToArray();
                    waterFactory.NewWaterSource(new Vector2(points[0], points[1]), flowInOut[0], flowInOut[1], flowInOut[2]);
                    timesWaterUsed++;
                    break;

                case "Net":
                    points = ReturnFloatsFromArg(arguments);
                    netFactory.Create(new Vector2(points[0], points[1]), new Vector2(points[2], points[3]), arguments[1]);
                    timesNetUsed++;
                    break;

                case "Building":
                    points = ReturnFloatsFromArg(arguments);
                    angle  = float.Parse(arguments[3], CultureInfo.InvariantCulture);
                    buildingFactory.Create(new Vector2(points[0], points[1]), angle, arguments[1]);
                    timesBuildingUsed++;
                    break;

                case "Tree":
                    points = ReturnFloatsFromArg(arguments);
                    treeFactory.Create(new Vector2(points[0], points[1]), arguments[1]);
                    timesTreeUsed++;
                    break;

                case "Prop":
                    points = ReturnFloatsFromArg(arguments);
                    angle  = float.Parse(arguments[3], CultureInfo.InvariantCulture);
                    propFactory.Create(new Vector2(points[0], points[1]), angle, arguments[1]);
                    timesPropUsed++;
                    break;

                case "Error":
                    UnityEngine.Debug.Log(arguments[1]);
                    break;

                default:
                    UnityEngine.Debug.Log(arguments[0]);
                    break;
                }
            }
        }
Пример #4
0
 private static Measurement.MakePerfTest MakePerfTestRange2MapMaker(TreeFactory <IRange2Map <int> > treeFactory, int count)
 {
     return(delegate() { return new PerfTestRange2Map(delegate(int _count) { return treeFactory.Create(_count); }, count); });
 }