public void SetUp()
 {
     var changer = new N2.Edit.Workflow.StateChanger();
     var activator = new ContentActivator(changer, MockRepository.GenerateStrictMock<IItemNotifier>(), new EmptyProxyFactory());
     DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), new Fakes.FakeTypeFinder(typeof(RestrictsChildWithCardinality), typeof(ChildWithCardinality)), new TransformerBase<IUniquelyNamed>[0], new EngineSection { Definitions = new DefinitionCollection { DefineUnattributedTypes = true } });
     definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer);
 }
Ejemplo n.º 2
0
        public void Configuration_CanAdd_Editable_ToDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Add(new ContainableElement {
                Name = "X", Type = typeof(EditableCheckBoxAttribute).AssemblyQualifiedName
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableCheckBoxAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(1));
        }
Ejemplo n.º 3
0
        public void GivenIHaveCreatedALinkedFixtureForFootballWithTheFollowingBaseVariables(Table table)
        {
            var baseVariables = table.CreateInstance <BaseVariables>();
            //
            //            var tradingRulesBuilder = new TradingRulesBuilder();
            //            var tradingRules = tradingRulesBuilder.ForSport(RestRelations.FootballOdds)
            //                                                  .WithDefaultRules()
            //                                                  .Build();

            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);
            //  var createdTradingRules = connectClient.CreateTradingRules(tradingRules);

            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(RestRelations.FootballOdds)
                                    .WithBaseVariables(baseVariables)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinition = connectClient.CreateDefinition(definition);

            var fixture = new FixtureBuilder().ForSport(RestRelations.FootballOdds)
                          .ForPublicFixture()
                          .Build();
            //   fixture.Participants[0].Name = "Priya1";
            //   fixture.Participants[1].Name = "Priya2";

            var publicCe = connectClient.CreatePublicFixture(fixture);

            var linkedCe = connectClient.CreateLinkedFixture(publicCe, createdDefinition);

            ScenarioContext.Current.Add(Constants.KeyLinkedCe, linkedCe);
        }
Ejemplo n.º 4
0
        public void Configuration_CanChange_Editable_OnExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(new DefinitionElement
            {
                Name      = "DefinitionTextPage",
                Editables = new ContainableCollection {
                    new ContainableElement {
                        Name  = "Title",
                        Title = "Page title in navigation",
                        Type  = typeof(EditableTextAttribute).AssemblyQualifiedName
                    }
                }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions    = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Title == "Page title in navigation" && e.GetType() == typeof(EditableTextAttribute)));
            Assert.That(textDefinition.Editables.Any(e => e.Title == "Title" || e.GetType() == typeof(WithEditableTitleAttribute)), Is.False);
        }
        public void GivenIHaveCreatedAPrematchLinkedFixtureForWithTheFollowingBaseVariables(string sport, Table table)
        {
            var prematchBaseVariables = new GTP.Domain.Sports.Cricket.PreMatchBaseVariables();
            var connectClient         = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            var definitionBuilder = new DefinitionBuilder().ForSport(RestRelations.CricketOdds)
                                    .WithBaseVariables(new GTP.Domain.Sports.Cricket.BaseVariables())
                                    .WithPreMatchBaseVariables(prematchBaseVariables)
                                    .WithDefaultTradingRules()
                                    .WithDefaultLadder();
            var definition = definitionBuilder.Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            var fixture = new FixtureBuilder().ForSport(RestRelations.CricketOdds)
                          .ForPublicFixture()
                          .Build();

            var publicFixtureResource = connectClient.CreatePublicFixture(fixture);

            var linkedFixtureResource = connectClient.CreateLinkedFixture(publicFixtureResource.Fixture,
                                                                          createdDefinitionResource.Definition);

            ScenarioContext.Current.Add(Constants.KeyLinkedCe, linkedFixtureResource);
        }
Ejemplo n.º 6
0
        public void Configuration_CanRemove_Editable_FromDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Remove(new ContainableElement {
                Name = "Text"
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableFreeTextAreaAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(0));
        }
        public void GivenIHaveCreatedADefinitionWithNewTwoRunnerLadderForSportWithFollowingBaseVariables(string ladderName, string sport, Table table)
        {
            var baseVariables = SharedStepsMarketDefinitions.CreateBaseVariables(sport, table);

            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            //Create a Two Runner Ladder with the specified name
            var ladderBuilder  = new LadderBuilder();
            var ladder         = ladderBuilder.WithName(ladderName).WithDefaultTwoRunnerSteps().Build();
            var ladderResource = connectClient.CreateLadder(ladder);

            var twoRunnerLadders = new List <Ladder>();

            twoRunnerLadders.Add(ladderResource.Ladder);

            //Create a definition with the two runner ladder created above
            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(Sports.ToRestRelation[sport])
                                    .WithBaseVariables(baseVariables)
                                    .WithTwoRunnerLadders(twoRunnerLadders)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            ScenarioContext.Current.Add(Constants.KeyDefinition, createdDefinitionResource);
            AddToCurrentScenarioContext(Constants.KeyLadder, ladderResource);
        }
Ejemplo n.º 8
0
 public DefinitionBuilder GetDefinitionBuilder()
 {
     if (_definitionBuilder == null)
     {
         var enabledLanguages = _settings.EnabledLanguages;
         if (enabledLanguages == null)
         {
             enabledLanguages = new string[] {}
         }
         ;
         _definitionBuilder =
             new DefinitionBuilder(
                 _settings.RootPath,
                 Environment.CurrentDirectory,
                 _settings.DefaultLanguage,
                 enabledLanguages,
                 () => {
             return(GetDefaultHandlers()
                    .Select(x =>
                            new BuiltInCommand(x.Command, x.Usage)));
         },
                 (path) => PluginLocator().LocateAllFor(path));
     }
     return(_definitionBuilder);
 }
Ejemplo n.º 9
0
        public void Configuration_CanAdd_Editable_ToExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection {
                DefineUnattributedTypes = true
            };

            definitionCollection.Add(new DefinitionElement
            {
                Name      = "DefinitionTextPage",
                Editables = new ContainableCollection {
                    new ContainableElement {
                        Name  = "MetaTitle",
                        Title = "Page title",
                        Type  = typeof(N2.Details.EditableTextAttribute).AssemblyQualifiedName
                    }
                }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase <IUniquelyNamed> [0], new EngineSection {
                Definitions = definitionCollection
            });

            var definitions    = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Name == "MetaTitle"));
        }
        public void GivenIHaveCreatedALinkedFixtureForAmericanFootballWithTheFollowingBaseVariables(string sport, Table table)
        {
            var baseVariables = CreateBaseVariables(sport, table);

            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(Sports.ToRestRelation[sport])
                                    .WithBaseVariables(baseVariables)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            var fixture = new FixtureBuilder().ForSport(Sports.ToRestRelation[sport])
                          .ForPublicFixture()
                          .Build();

            var publicFixtureResource = connectClient.CreatePublicFixture(fixture);

            var linkedFixtureResource = connectClient.CreateLinkedFixture(publicFixtureResource.Fixture,
                                                                          createdDefinitionResource.Definition);

            ScenarioContext.Current.Add(Constants.KeyLinkedCe, linkedFixtureResource);
        }
Ejemplo n.º 11
0
        public override void SetUp()
        {
            base.SetUp();
            DefinitionBuilder builder  = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase <IUniquelyNamed> [0], TestSupport.SetupEngineSection());
            IItemNotifier     notifier = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();

            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ContentActivator(changer, notifier, new EmptyProxyFactory()), changer, new DefinitionMap());

            versioner = mocks.StrictMock <IVersionManager>();
            var urls = new FakeEditUrlManager();

            editManager = new EditManager(definitions, persister, versioner, null, null, null, urls, changer, new EditableHierarchyBuilder(new SecurityManager(new ThreadContext(), new EditSection()), TestSupport.SetupEngineSection()), new EditSection());
            editManager.EnableVersioning = true;

            var engine = new FakeEngine();

            engine.Container.AddComponentInstance("editManager", typeof(IEditManager), editManager);

            engine.Container.AddComponentInstance("editSection", typeof(EditSection), new EditSection());

            Context.Replace(engine);
        }
Ejemplo n.º 12
0
        public static string GenerateMapping(IList <IDev2Definition> defs, enDev2ArgumentType typeOf)
        {
            var b = new DefinitionBuilder {
                ArgumentType = typeOf, Definitions = defs
            };

            return(b.Generate());
        }
Ejemplo n.º 13
0
        public static IDefinitionProvider[] SetupDefinitionProviders(DefinitionMap map, params Type[] itemTypes)
        {
            IDefinitionProvider[] definitionProviders;
            ITypeFinder           typeFinder = new Fakes.FakeTypeFinder(itemTypes.Select(t => t.Assembly).FirstOrDefault() ?? Assembly.GetExecutingAssembly(), itemTypes);

            var definitionBuilder = new DefinitionBuilder(map, typeFinder, new TransformerBase <IUniquelyNamed> [0], SetupEngineSection());

            definitionProviders = new IDefinitionProvider[] { new DefinitionProvider(definitionBuilder) };
            return(definitionProviders);
        }
Ejemplo n.º 14
0
        public ViewTemplateProvider(ViewTemplateRegistrator registrator, ViewTemplateAnalyzer analyzer, ContentActivator activator, DefinitionBuilder builder, IProvider <HttpContextBase> httpContextProvider, IProvider <VirtualPathProvider> vppProvider)
        {
            this.registrator         = registrator;
            this.analyzer            = analyzer;
            this.activator           = activator;
            this.builder             = builder;
            this.httpContextProvider = httpContextProvider;
            this.vppProvider         = vppProvider;

            registrator.RegistrationAdded += (s, a) => rebuild = true;
        }
Ejemplo n.º 15
0
        public ViewTemplateProvider(ViewTemplateRegistrator registrator, ViewTemplateAnalyzer analyzer, ContentActivator activator, DefinitionBuilder builder, IProvider<HttpContextBase> httpContextProvider, IProvider<VirtualPathProvider> vppProvider)
        {
            this.registrator = registrator;
            this.analyzer = analyzer;
            this.activator = activator;
            this.builder = builder;
            this.httpContextProvider = httpContextProvider;
            this.vppProvider = vppProvider;

            registrator.RegistrationAdded += (s, a) => rebuild = true;
        }
        public void Configuration_CanAdd_Definition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(new DefinitionElement { Name = "DefinitionUndefined", Type = typeof(DefinitionUndefined).AssemblyQualifiedName });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var undefinedDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionUndefined));

            Assert.That(undefinedDefinition.IsDefined, Is.True);
        }
Ejemplo n.º 17
0
        public void Configuration_CanRemove_Definition()
        {
            var definitionCollection = new DefinitionCollection { DefineUnattributedTypes = true };
            definitionCollection.Remove(new DefinitionElement { Name = "DefinitionTextPage" });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinitions = definitions
                .Where(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textPageDefinitions.Count(), Is.EqualTo(0));
        }
        public void Configuration_CanRemove_Definition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Remove(new DefinitionElement { Name = "DefinitionTextPage" });
            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinitions = definitions
                .Where(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textPageDefinitions.Count(), Is.EqualTo(0));
        }
Ejemplo n.º 19
0
        public void SetUp()
        {
            var changer               = new N2.Edit.Workflow.StateChanger();
            var activator             = new ContentActivator(changer, MockRepository.GenerateStrictMock <IItemNotifier>(), new EmptyProxyFactory());
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), new Fakes.FakeTypeFinder(typeof(RestrictsChildWithCardinality), typeof(ChildWithCardinality)), new TransformerBase <IUniquelyNamed> [0], new EngineSection {
                Definitions = new DefinitionCollection {
                    DefineUnattributedTypes = true
                }
            });

            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, activator, changer, new DefinitionMap());
        }
Ejemplo n.º 20
0
        public static void Setup(out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out InterceptingProxyFactory proxyFactory, params Type[] itemTypes)
        {
            ITypeFinder typeFinder = new Fakes.FakeTypeFinder(itemTypes[0].Assembly, itemTypes);

            DefinitionBuilder definitionBuilder = new DefinitionBuilder(typeFinder, new EngineSection());

            notifier     = new ItemNotifier();
            proxyFactory = new InterceptingProxyFactory();
            activator    = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, proxyFactory);
            definitions  = new DefinitionManager(new [] { new DefinitionProvider(definitionBuilder) }, activator);
            ((DefinitionManager)definitions).Start();
        }
Ejemplo n.º 21
0
        public override void SetUp()
        {
            base.SetUp();

            user = CreatePrincipal("SomeSchmuck");

            DefinitionBuilder builder  = new DefinitionBuilder(typeFinder, new EngineSection());
            IItemNotifier     notifier = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            activator   = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, new EmptyProxyFactory());
            definitions = new DefinitionManager(new [] { new DefinitionProvider(builder) }, activator);
        }
Ejemplo n.º 22
0
        public static void Setup(out IDefinitionProvider[] definitionProviders, out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out InterceptingProxyFactory proxyFactory, params Type[] itemTypes)
        {
            ITypeFinder typeFinder = new Fakes.FakeTypeFinder(itemTypes[0].Assembly, itemTypes);

            DefinitionBuilder definitionBuilder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase <IUniquelyNamed> [0], SetupEngineSection());

            notifier            = new ItemNotifier();
            proxyFactory        = new InterceptingProxyFactory();
            activator           = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, proxyFactory);
            definitionProviders = new IDefinitionProvider[] { new DefinitionProvider(definitionBuilder) };
            definitions         = new DefinitionManager(definitionProviders, new ITemplateProvider[0], activator, new StateChanger());
            ((DefinitionManager)definitions).Start();
        }
Ejemplo n.º 23
0
		public override void SetUp()
		{
			base.SetUp();

			user = CreatePrincipal("SomeSchmuck");

			map = new DefinitionMap();
			DefinitionBuilder builder = new DefinitionBuilder(map, typeFinder, new TransformerBase<IUniquelyNamed>[0], new EngineSection());
			IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
			mocks.Replay(notifier);
			var changer = new N2.Edit.Workflow.StateChanger();
			activator = new ContentActivator(changer, notifier, new EmptyProxyFactory());
			definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer);
		}
Ejemplo n.º 24
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            ReadSignature();
            NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureReader.ReturnType);

            NuGenAssembly assembly = BaseTypeDefinition.ModuleScope.Assembly;

            DefinitionBuilder.Length = 0;

            if ((Flags & CorPropertyAttr.prSpecialName) == CorPropertyAttr.prSpecialName)
            {
                DefinitionBuilder.Append("specialname ");
            }

            CorPropertyAttr reservedFlags = Flags & CorPropertyAttr.prReservedMask;

            if ((reservedFlags & CorPropertyAttr.prRTSpecialName) == CorPropertyAttr.prRTSpecialName)
            {
                DefinitionBuilder.Append("rtsspecialname ");
            }

            if ((signatureReader.CallingConvention & CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS) == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS)
            {
                DefinitionBuilder.Append("instance ");
            }

            DefinitionBuilder.Append(signatureReader.ReturnType);
            DefinitionBuilder.Append(" ");
            DefinitionBuilder.Append(Name);
            DefinitionBuilder.Append("(");

            if (signatureReader.Parameters != null)
            {
                for (int parametersIndex = 0; parametersIndex < signatureReader.Parameters.Count; parametersIndex++)
                {
                    NuGenBaseSignatureItem parameter = signatureReader.Parameters[parametersIndex];
                    NuGenHelperFunctions.SetSignatureItemToken(allTokens, parameter);
                    DefinitionBuilder.Append(parameter);

                    if (parametersIndex < signatureReader.Parameters.Count - 1)
                    {
                        DefinitionBuilder.Append(", ");
                    }
                }
            }

            DefinitionBuilder.Append(")");
            Definition = DefinitionBuilder.ToString();
        }
        public void GivenICreateAMarketDefinitionWithBaseVariablesThatHaveTheProperties(string sport, Table table)
        {
            var baseVariables = SharedStepsMarketDefinitions.CreateBaseVariables(sport, table);
            var definition    = new DefinitionBuilder().ForSport(Sports.ToRestRelation[sport])
                                .WithBaseVariables(baseVariables)
                                .WithDefaultLadder()
                                .WithDefaultTradingRules()
                                .Build();

            var connectClient             = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);
            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            ScenarioContext.Current.Add(Constants.KeyDefinition, createdDefinitionResource);
        }
Ejemplo n.º 26
0
        public static async Task WriteToFile(Options options, DefinitionBuilder builder, IEnumerable source)
        {
            var filename  = Path.Combine(options.OutputDirectory, builder.Name + ".csv");
            var directory = new DirectoryInfo(options.OutputDirectory);

            if (!directory.Exists && directory.Parent != null)
            {
                directory.Create();
            }

            var dbLoader = new BulkLoader(builder.Name, source);
            await dbLoader.ExportToFile(filename);

            Console.WriteLine($"Exported {builder.Name} to CSV");
        }
        public void GivenIHaveCreatedANewMarketDefinitionForWithTheFollowingBaseVariables(string sport, Table table)
        {
            var baseVariables = CreateBaseVariables(sport, table);
            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(Sports.ToRestRelation[sport])
                                    .WithBaseVariables(baseVariables)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            ScenarioContext.Current.Add(Constants.KeyDefinition, createdDefinitionResource);
        }
Ejemplo n.º 28
0
        public override void SetUp()
        {
            base.SetUp();

            user = CreatePrincipal("SomeSchmuck");

            map = new DefinitionMap();
            DefinitionBuilder builder  = new DefinitionBuilder(map, typeFinder, new TransformerBase <IUniquelyNamed> [0], new EngineSection());
            IItemNotifier     notifier = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();

            activator   = new ContentActivator(changer, notifier, new EmptyProxyFactory());
            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer);
        }
Ejemplo n.º 29
0
 public ContentPartTemplateProvider(
     ContentActivator activator,
     DefinitionBuilder builder,
     IProvider <HttpContextBase> httpContextProvider,
     //IProvider<VirtualPathProvider> vppProvider,
     //IRepository<ContentItem> repository,
     ConnectionMonitor connection,
     IHost host)
 {
     _activator           = activator;
     _builder             = builder;
     _httpContextProvider = httpContextProvider;
     _connection          = connection;
     //_vpp = vppProvider.Get();
     //_repository = repository;
     _host = host;
 }
		public ContentPartTemplateProvider(
			ContentActivator activator, 
			DefinitionBuilder builder, 
			IProvider<HttpContextBase> httpContextProvider, 
			//IProvider<VirtualPathProvider> vppProvider, 
			//IRepository<ContentItem> repository, 
			ConnectionMonitor connection,
			IHost host)
		{
			_activator = activator;
			_builder = builder;
			_httpContextProvider = httpContextProvider;
			_connection = connection;
			//_vpp = vppProvider.Get();
			//_repository = repository;
			_host = host;
		}
Ejemplo n.º 31
0
        public static string GenerateSerializableDefsFromDataList(string datalist, enDev2ColumnArgumentDirection direction)
        {
            DefinitionBuilder db = new DefinitionBuilder();

            if (direction == enDev2ColumnArgumentDirection.Input)
            {
                db.ArgumentType = enDev2ArgumentType.Input;
            }
            else if (direction == enDev2ColumnArgumentDirection.Output)
            {
                db.ArgumentType = enDev2ArgumentType.Output;
            }

            db.Definitions = GenerateDefsFromDataList(datalist, direction);

            return(db.Generate());
        }
Ejemplo n.º 32
0
        public void Configuration_CanAdd_Definition()
        {
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(new DefinitionElement {
                Name = "DefinitionUndefined", Type = typeof(DefinitionUndefined).AssemblyQualifiedName
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions         = builder.GetDefinitions();
            var undefinedDefinition = definitions
                                      .Single(d => d.ItemType == typeof(DefinitionUndefined));

            Assert.That(undefinedDefinition.IsDefined, Is.True);
        }
Ejemplo n.º 33
0
        public void Configuration_CanRemove_Definition()
        {
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Remove(new DefinitionElement {
                Name = "DefinitionTextPage"
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions         = builder.GetDefinitions();
            var textPageDefinitions = definitions
                                      .Where(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textPageDefinitions.Count(), Is.EqualTo(0));
        }
        public void Configuration_CanAdd_Editable_ToExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(new DefinitionElement
            {
                Name = "DefinitionTextPage",
                Editables = new ContainableCollection { new ContainableElement {
                    Name = "MetaTitle",
                    Title = "Page title",
                    Type = typeof(N2.Details.EditableTextAttribute).AssemblyQualifiedName } }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Name == "MetaTitle"));
        }
        public void Configuration_CanAdd_Editable_ToDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement { Name = "DefinitionTextPage" };
            definitionElement.Containers.Add(new ContainableElement { Name = "X", Type = typeof(EditableCheckBoxAttribute).AssemblyQualifiedName });
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                .Where(e => e.GetType() == typeof(EditableCheckBoxAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(1));
        }
        public void Configuration_CanRemove_Editable_FromDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement { Name = "DefinitionTextPage" };
            definitionElement.Containers.Remove(new ContainableElement { Name = "Text" });
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                .Where(e => e.GetType() == typeof(EditableFreeTextAreaAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(0));
        }
Ejemplo n.º 37
0
        private static async Task Run(Options options)
        {
            options.Validate();

            var dbdProvider = new GithubDBDProvider();
            var dbcProvider = new LocalDBCProvider(options.Directory);

            var dbs = Utils.GetFiles(options.Directory, "*.db2|*.dbc")
                      .ToDictionary(Path.GetFileNameWithoutExtension);

            foreach (var db in dbs)
            {
                var dbcStream = await dbcProvider.StreamForTableName(db.Key);

                var dbdStream = await dbdProvider.StreamForTableName(db.Key);

                var dbReader   = new DBReader(dbcStream);
                var builder    = new DefinitionBuilder(db.Key, options.Build);
                var definition = builder.Generate(dbReader, dbdStream, dbs);
                var storage    = dbReader.GetRecords(definition);

                if (storage.Count == 0)
                {
                    Console.WriteLine($"Skipping {db.Key} - empty");
                    continue;
                }

                if (options.ExportType.HasFlag(ExportType.SQL))
                {
                    await DBObjectWriter.WriteToServer(options, builder, storage.Values);
                }
                if (options.ExportType.HasFlag(ExportType.CSV))
                {
                    await CSVObjectWriter.WriteToFile(options, builder, storage.Values);
                }
            }

            // append foreign keys to the database
            if (options.ExportType.HasFlag(ExportType.SQL) && options.ExportForeignKeys)
            {
                Console.WriteLine("Generating foreign keys");
                await DBObjectWriter.WriteForeignKeys(options);
            }
        }
Ejemplo n.º 38
0
        public void Configuration_CanChange_Editable_OnExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection { DefineUnattributedTypes = true };
            definitionCollection.Add(new DefinitionElement
            {
                Name = "DefinitionTextPage",
                Editables = new ContainableCollection { new ContainableElement {
                    Name = "Title",
                    Title = "Page title in navigation",
                    Type = typeof(EditableTextAttribute).AssemblyQualifiedName } }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Title == "Page title in navigation" && e.GetType() == typeof(EditableTextAttribute)));
            Assert.That(textDefinition.Editables.Any(e => e.Title == "Title" || e.GetType() == typeof(WithEditableTitleAttribute)), Is.False);
        }
Ejemplo n.º 39
0
		public override void SetUp()
		{
			base.SetUp();

			CreatePersister();

			parser = mocks.StrictMock<IUrlParser>();

			ITypeFinder typeFinder = CreateTypeFinder();
			DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], TestSupport.SetupEngineSection());
			IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
			mocks.Replay(notifier);
			var changer = new N2.Edit.Workflow.StateChanger();
			activator = new ContentActivator(changer, notifier, new EmptyProxyFactory());
			definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer, new DefinitionMap());
			finder = new FakeItemFinder(() => Enumerable.Empty<ContentItem>());
			integrityManger = new IntegrityManager(definitions, finder, parser);
			IntegrityEnforcer enforcer = new IntegrityEnforcer(persister, integrityManger, activator);
			enforcer.Start();
		}
        public void GivenIHaveCreatedANewFixtureSetupInModeForWithFollowingBaseVariables(string tradeModeStr,
                                                                                         string sport, Table table)
        {
            // Parse
            var tradeMode = (TradeMode)Enum.Parse(typeof(TradeMode), tradeModeStr);

            var baseVariables = CreateBaseVariables(sport, table);

            //Get Client
            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            //Create Definition
            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(Sports.ToRestRelation[sport])
                                    .WithBaseVariables(baseVariables)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            //Create public Fixture
            var fixture = new FixtureBuilder().ForSport(Sports.ToRestRelation[sport])
                          .ForPublicFixture()
                          .Build();

            var publicFixtureResource = connectClient.CreatePublicFixture(fixture);

            var linkedFixtureResource = connectClient.CreateLinkedFixture(publicFixtureResource.Fixture,
                                                                          createdDefinitionResource.Definition);


            // Update trade mode
            if (linkedFixtureResource.Fixture.TradeMode != tradeMode)
            {
                linkedFixtureResource.Fixture.TradeMode = tradeMode;
                linkedFixtureResource = connectClient.UpdateFixture(linkedFixtureResource);
            }

            ScenarioContext.Current.Add(Constants.KeyLinkedCe, linkedFixtureResource);
        }
Ejemplo n.º 41
0
        public override void SetUp()
        {
            base.SetUp();
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], TestSupport.SetupEngineSection());
            IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();
            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ContentActivator(changer, notifier, new EmptyProxyFactory()), changer, new DefinitionMap());

            versioner = mocks.StrictMock<IVersionManager>();
            var urls = new FakeEditUrlManager();
            editManager = new EditManager(definitions, persister, versioner, null, null, urls, changer, new EditableHierarchyBuilder(new SecurityManager(new ThreadContext(), new EditSection()), TestSupport.SetupEngineSection()), new EditSection());
            editManager.EnableVersioning = true;

            var engine = new FakeEngine();
            engine.Container.AddComponentInstance("editManager", typeof(IEditManager), editManager);

            engine.Container.AddComponentInstance("editSection", typeof(EditSection), new EditSection());

            Context.Replace(engine);
        }
        public void GivenIHaveCreatedNewTwoRunnerDefaultLadderWithTheNameAndANewDefinitionAsForWithDefaultBaseVariables(string ladderName, string definitionName, string sport)
        {
            var baseVariables = SharedStepsMarketDefinitions.CreateDefaultBaseVariables(sport);
            var connectClient = ScenarioContext.Current.Get <ConnectClient>(Constants.KeyConnectClient);

            var definitionBuilder = new DefinitionBuilder();
            var definition        = definitionBuilder.ForSport(Sports.ToRestRelation[sport])
                                    .WithBaseVariables(baseVariables)
                                    .WithDefaultLadder()
                                    .WithDefaultTradingRules()
                                    .Build();

            var createdDefinitionResource = connectClient.CreateDefinition(definition);

            var ladderBuilder  = new LadderBuilder();
            var ladder         = ladderBuilder.WithName(ladderName).WithDefaultTwoRunnerSteps().Build();
            var ladderResource = connectClient.CreateLadder(ladder);

            ScenarioContext.Current.Add(Constants.KeyDefinition, createdDefinitionResource);
            AddToCurrentScenarioContext(Constants.KeyLadder, ladderResource);
        }
Ejemplo n.º 43
0
        public override void SetUp()
        {
            base.SetUp();
            var urls = new FakeEditUrlManager();
            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection(), urls);
            IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();
            DefinitionManager definitions = new DefinitionManager(builder, changer, notifier, new EmptyProxyFactory());

            versioner = mocks.StrictMock<IVersionManager>();
            editManager = new EditManager(definitions, persister, versioner, null, null, null, urls, changer, new EditSection());
            editManager.EnableVersioning = true;

            var engine = new FakeEngine();
            engine.AddComponentInstance("editManager", typeof(IEditManager), editManager);

            engine.AddComponentInstance("editSection", typeof(EditSection), new EditSection());

            Context.Replace(engine);
        }
Ejemplo n.º 44
0
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();

            parser = mocks.StrictMock <IUrlParser>();

            ITypeFinder       typeFinder = CreateTypeFinder();
            DefinitionBuilder builder    = new DefinitionBuilder(typeFinder, new EngineSection());
            IItemNotifier     notifier   = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            activator       = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, new EmptyProxyFactory());
            definitions     = new DefinitionManager(new [] { new DefinitionProvider(builder) }, activator);
            finder          = new FakeItemFinder(definitions, () => Enumerable.Empty <ContentItem>());
            integrityManger = new IntegrityManager(definitions, finder, parser);
            IntegrityEnforcer enforcer = new IntegrityEnforcer(persister, integrityManger, activator);

            enforcer.Start();
        }
Ejemplo n.º 45
0
 public DefinitionProvider(DefinitionBuilder definitionBuilder)
 {
     this.definitions = definitionBuilder.GetDefinitions().ToArray();
 }
Ejemplo n.º 46
0
        public override void SetUp()
        {
            base.SetUp();

            builder = new DefinitionBuilder(typeFinder, new EngineSection());
        }
Ejemplo n.º 47
0
 public ViewTemplateAnalyzer(IProvider<ViewEngineCollection> viewEnginesProvider, DefinitionMap map, DefinitionBuilder builder)
 {
     this.viewEnginesProvider = viewEnginesProvider;
     this.map = map;
     this.builder = builder;
 }
 public ContentTemplateProvider(ContentTemplateRepository repository, DefinitionBuilder definitionBuilder)
 {
     this.repository = repository;
     this.definitionBuilder = definitionBuilder;
 }
Ejemplo n.º 49
0
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();

            parser = mocks.StrictMock<IUrlParser>();

            ITypeFinder typeFinder = CreateTypeFinder();
            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection(), new FakeEditUrlManager());
            IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
            mocks.Replay(notifier);
            definitions = new DefinitionManager(builder, new N2.Edit.Workflow.StateChanger(), notifier, new EmptyProxyFactory());
            finder = new FakeItemFinder(definitions, () => Enumerable.Empty<ContentItem>());
            integrityManger = new IntegrityManager(definitions, finder, parser);
            IntegrityEnforcer enforcer = new IntegrityEnforcer(persister, integrityManger, definitions);
            enforcer.Start();
        }
Ejemplo n.º 50
0
        public override void SetUp()
        {
            base.SetUp();

            user = CreatePrincipal("SomeSchmuck");

            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection(), new FakeEditUrlManager());
            IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
            mocks.Replay(notifier);
            definitions = new DefinitionManager(builder, new N2.Edit.Workflow.StateChanger(), notifier, new EmptyProxyFactory());
        }
Ejemplo n.º 51
0
 public DefinitionProvider(DefinitionBuilder definitionBuilder)
 {
     this.definitionBuilder = definitionBuilder;
 }
Ejemplo n.º 52
0
		public override void SetUp()
		{
			base.SetUp();

			builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], TestSupport.SetupEngineSection());
		}