public void starts_stops_and_stores_the_timer()
        {
            var autoEvent = new AutoResetEvent(false);
            var clean     = false;
            var service   = new LambdaHttpService(() => { autoEvent.Set(); }, () => { clean = true; })
            {
                Interval = 100
            };

            var services = new InMemoryServiceLocator();

            services.Add(service);

            var storage = new ThreadHttpApplicationStorage();
            var manager = new HttpTimerManager(services, storage, new NulloLogger());

            manager.Start <LambdaHttpService>();
            autoEvent.WaitOne(1000);

            var key = HttpTimerManager.ResolveKey <LambdaHttpService>();

            storage.Has(key).ShouldBeTrue();

            manager.Stop <LambdaHttpService>();

            storage.Has(key).ShouldBeFalse();

            clean.ShouldBeTrue();
        }
        public void determine_the_mode_uses_the_last_matching_policy()
        {
            var accessor = SingleProperty.Build <ValidationModeTarget>(x => x.Property);
            var services = new InMemoryServiceLocator();

            services.Add(new AccessorRules());
            var mode = ValidationMode.Triggered;

            var p1 = MockRepository.GenerateStub <IValidationModePolicy>();

            p1.Stub(x => x.Matches(services, accessor)).Return(true);
            p1.Stub(x => x.DetermineMode(services, accessor)).Return(ValidationMode.Live);

            var p2 = MockRepository.GenerateStub <IValidationModePolicy>();

            p2.Stub(x => x.Matches(services, accessor)).Return(true);
            p2.Stub(x => x.DetermineMode(services, accessor)).Return(mode);

            var node = new ValidationNode();

            node.DefaultMode(ValidationMode.Live);
            node.RegisterPolicy(p1);
            node.RegisterPolicy(p2);

            node.As <IValidationNode>().DetermineMode(services, accessor).ShouldEqual(mode);
        }
Exemple #3
0
        public void displays_string_value_inside_of_a_span()
        {
            var stringifier = new Stringifier();

            stringifier.AddStrategy(new StringifierStrategy
            {
                Matches        = r => true,
                StringFunction = r => "*" + r.RawValue + "*"
            });

            var services = new InMemoryServiceLocator();

            services.Add(stringifier);
            services.Add <IDisplayFormatter>(new DisplayFormatter(services, stringifier));

            var request = ElementRequest.For <ElementRequestTester.Model1>(new ElementRequestTester.Model1 {
                Child = new ElementRequestTester.Model2 {
                    Name = "Little Lindsey"
                }
            }, x => x.Child.Name);

            request.Attach(services);
            request.ElementId = "something";

            var tag = new SpanDisplayBuilder().Build(request);

            tag.ToString().ShouldEqual("<span id=\"something\">*Little Lindsey*</span>");
        }
Exemple #4
0
 public ScenarioDefinition()
 {
     Tag      = new HtmlTag("input");
     Services = new InMemoryServiceLocator();
     Modifier = new T();
     Services.Add(ValidationGraph.BasicGraph());
 }
Exemple #5
0
        public void parses_the_field()
        {
            var settings = new SchemaMetadataSettings
            {
                Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Clarify", "Metadata", SchemaMetadataSettings.FileName)
            };

            var visitors = new List <IXElementVisitor> {
                new ParseTables(), new ParseFields()
            };
            var service  = new XElementService(visitors);
            var services = new InMemoryServiceLocator();

            services.Add <IXElementService>(service);
            services.Add <IXElementSerializer>(new XElementSerializer());

            var cache = new SchemaMetadataCache(settings, new NulloLogger(), service, services);

            // Other tables shouldn't exist but will never be null
            cache.MetadataFor("test").ShouldNotBeNull();

            var table = cache.MetadataFor("case");

            // Other fields shouldn't exist but will also never be null
            table.MetadataFor("test").ShouldNotBeNull();
            var field = table.MetadataFor("creation_time");

            field.IsDateOnlyField().ShouldBeTrue();
        }
        public void sets_the_value_from_a_field_argument()
        {
            var transform = new StubTransform();
            var services  = new InMemoryServiceLocator();

            services.Add <ISimpleService>(new SimpleService());
            services.Add <IMappingVariableExpander>(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services));

            var path = ModelDataPath.Parse("child.grandChild.property");

            var data = new ModelData();

            data["child"] = new ModelData();
            data["test"]  = "testing";
            data.Child("child")["grandChild"] = new ModelData();

            var arguments = new List <ITransformArgument>
            {
                new FieldArgument("foo", ModelDataPath.Parse("test"))
            };

            var configuredTransform = new ConfiguredTransform(path, transform, arguments, new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services), services);

            configuredTransform.Execute(data, services);

            data.Child("child").Child("grandChild").Get <string>("property").ShouldEqual("TESTING");
        }
Exemple #7
0
        private FormRequest createRequest()
        {
            var rules     = new AccessorRules();
            var overrides = new ValidationOptionsTargetOverrides().As <IAccessorRulesRegistration>();

            overrides.AddRules(rules);

            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(theGraph));
            services.Add(rules);
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest()));
            services.Add <ITypeResolver>(new TypeResolver());
            services.Add <ITypeDescriptorCache>(new TypeDescriptorCache());

            var graph = ValidationGraph.BasicGraph();

            graph.Fields.FindWith(new AccessorRulesFieldSource(rules));

            services.Add(graph);

            var request = new FormRequest(new ChainSearch {
                Type = typeof(ValidationOptionsTarget)
            }, new ValidationOptionsTarget());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            return(request);
        }
 public void SetUp()
 {
     theLog = new InMemoryScriptLog();
     theServices = new InMemoryServiceLocator();
     theExectuter = new StubIfBlockExecuter();
     theReporter = new ActionReporter(Guid.NewGuid().ToString(), theLog, theExectuter);
 }
        private FormRequest requestFor <T>() where T : class, new()
        {
            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(theGraph));
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest()));

            theRequest      = new InMemoryFubuRequest();
            theNotification = Notification.Valid();
            theRequest.Set(theNotification);

            services.Add(theRequest);

            var request = new FormRequest(new ChainSearch {
                Type = typeof(T)
            }, new T());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            theContinuation = AjaxContinuation.Successful();
            theContinuation.ShouldRefresh = true;

            var resolver = MockRepository.GenerateStub <IAjaxContinuationResolver>();

            resolver.Stub(x => x.Resolve(theNotification)).Return(theContinuation);

            services.Add(resolver);

            return(request);
        }
        public void reading_settings()
        {
            var channel = new ChannelSettings
            {
                Outbound = new Uri("channel://outbound"),
                Downstream = new Uri("channel://downstream")
            };

            var bus = new BusSettings
            {
                Outbound = new Uri("bus://outbound"),
                Downstream = new Uri("bus://downstream")
            };

            var services = new InMemoryServiceLocator();
            services.Add(channel);
            services.Add(bus);

            var graph = new ChannelGraph();
            graph.ChannelFor<ChannelSettings>(x => x.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream);

            graph.ReadSettings(services);

            graph.ChannelFor<ChannelSettings>(x => x.Outbound)
                 .Uri.ShouldBe(channel.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream)
                 .Uri.ShouldBe(channel.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound)
                .Uri.ShouldBe(bus.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream)
                .Uri.ShouldBe(bus.Downstream);
        }
        public void add_and_retrieve_service()
        {
            var service = new InMemoryServiceLocator();

            service.Add <int>(5);

            service.GetInstance <int>().ShouldEqual(5);
        }
Exemple #12
0
        public HistoryMapParsingScenario(string tempPath, string[] files, InMemoryServiceLocator services)
        {
            _tempPath = tempPath;
            _files    = files;
            _services = services;

            _filter = new Lazy <ModelMap.ModelMap>(parseMap);
        }
Exemple #13
0
        public SimpleExecutionContext()
        {
            Services = new InMemoryServiceLocator();
            BindingRegistry = new BindingRegistry();

            var stringifier = new Stringifier();
            Services.Add(stringifier);
        }
        public void SetUp()
        {
            theServices = new InMemoryServiceLocator();

            theGameState = new SimpleGameState(new NewGameParser(Enumerable.Empty<ITagTransformer>()), new RoundtimeHandler(theServices));

            theServices.Add<IGameState>(theGameState);
        }
        public static ObjectBlockWriter Basic(BlockRegistry registry)
        {
            var services = new InMemoryServiceLocator();

            services.Add <IDisplayFormatter>(new DisplayFormatter(services, new Stringifier()));

            return(new ObjectBlockWriter(new TypeDescriptorCache(), services, BlockWriterLibrary.Basic(), registry));
        }
        public void add_and_retrieve_service()
        {
            var service = new InMemoryServiceLocator();

            service.Add<int>(5);

            service.GetInstance<int>().ShouldEqual(5);
        }
        public void resolves_the_value()
        {
            var value    = new DynamicValue("${foo}");
            var services = new InMemoryServiceLocator();

            services.Add <IMappingVariableExpander>(new StubExpander());

            value.Resolve(services).ShouldEqual("bar");
        }
        public void verify_any_happy_path()
        {
            var theFoo = new Foo();
            var services = new InMemoryServiceLocator();
            services.Add(new EnvironmentTestExtensions.Holder<IFoo>(new IFoo[]{theFoo}));

            services.VerifyAnyRegistrations<IFoo>(theLog);
            theLog.Success.ShouldBeTrue();
        }
        public void verify_any_empty()
        {
            var services = new InMemoryServiceLocator();
            services.Add(new EnvironmentTestExtensions.Holder<IFoo>(new IFoo[0] ));

            services.VerifyAnyRegistrations<IFoo>(theLog);
            theLog.Success.ShouldBeFalse();
            theLog.FullTraceText().ShouldContain("No implementations of {0} are registered".ToFormat(typeof(IFoo).FullName));
        }
Exemple #20
0
        public static ObjectResolver Basic()
        {
            var services = new InMemoryServiceLocator();
            var resolver = new ObjectResolver(services, new BindingRegistry(), new NulloBindingLogger());

            services.Add <IObjectResolver>(resolver);

            return(resolver);
        }
 public void SetUp()
 {
     theInstruction = new BeginWhen();
     theSettings    = new HistorySettings();
     theServices    = new InMemoryServiceLocator();
     theServices.Add(theSettings);
     theServices.Add <IActEntryConditionRegistry>(new ActEntryConditionRegistry());
     theContext = new ActEntryConditionContext(new WorkflowObject(), theServices);
 }
        public void SetUp()
        {
            var services = new InMemoryServiceLocator();

            theDocument = new FubuHtmlDocument(services);
            theDocument.Push("div");

            theBuilder = new DetailTableBuilder(theDocument);
        }
Exemple #23
0
        public void SetUp()
        {
            var locator = new InMemoryServiceLocator();

            locator.Add <WidgetFinderService>(new WidgetFinderService());

            var library = new ConverterLibrary(new IObjectConverterFamily[] { new WidgetFinderStrategy2() });

            finder = new ObjectConverter(locator, library);
        }
Exemple #24
0
        public void SetUp()
        {
            var services = new InMemoryServiceLocator();


            theDocument = new FubuHtmlDocument(services);
            theDocument.Push("div");

            theBuilder = new DetailTableBuilder(theDocument);
        }
        public void verify_any_happy_path()
        {
            var theFoo   = new Foo();
            var services = new InMemoryServiceLocator();

            services.Add(new EnvironmentTestExtensions.Holder <IFoo>(new IFoo[] { theFoo }));

            services.VerifyAnyRegistrations <IFoo>(theLog);
            theLog.Success.ShouldBeTrue();
        }
        public void beforeEach()
        {
            theRawRequest = new InMemoryRequestData();

            var services = new InMemoryServiceLocator();

            services.Add <IObjectConverter>(new ObjectConverter());

            ClassUnderTest = new BindingContext(theRawRequest, services, new NulloBindingLogger());
        }
        public void verify_any_empty()
        {
            var services = new InMemoryServiceLocator();

            services.Add(new EnvironmentTestExtensions.Holder <IFoo>(new IFoo[0]));

            services.VerifyAnyRegistrations <IFoo>(theLog);
            theLog.Success.ShouldBeFalse();
            theLog.FullTraceText().ShouldContain("No implementations of {0} are registered".ToFormat(typeof(IFoo).FullName));
        }
Exemple #28
0
            public ParsingExpression()
            {
                _files    = new List <string>();
                _tempPath = Path.GetTempPath().AppendPath(Guid.NewGuid().ToString());
                Directory.CreateDirectory(_tempPath);

                _services = new InMemoryServiceLocator();
                _services.Add(new HistorySettings {
                    Directory = _tempPath
                });
            }
Exemple #29
0
        public void gets_the_service()
        {
            var theServices = new InMemoryServiceLocator();
            var theService  = new TestService();

            theServices.Add(theService);

            theContext.ServiceLocator = theServices;

            theContext.Service <TestService>().ShouldBeTheSameAs(theService);
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theLocator = new InMemoryServiceLocator();
            theLogger = new NullLog();

            theSocket = new StubAsyncSocket();

            theLocator.Add<IAsyncSocket>(theSocket);

            theGameServer = new SimpleGameServer(theGameState, theLogger, theLocator);
        }
Exemple #31
0
        public void activate_should_attach_the_service_locator_to_the_subject()
        {
            var services = new InMemoryServiceLocator();

            var activator = new ServiceLocatorTagRequestActivator(services);

            var subject = new SubjectThatIsServiceAware();

            activator.Activate(subject);

            subject.Services.ShouldBeTheSameAs(services);
        }
        public void activate_should_attach_the_service_locator_to_the_subject()
        {
            var services = new InMemoryServiceLocator();

            var activator = new ServiceLocatorTagRequestActivator(services);

            var subject = new SubjectThatIsServiceAware();

            activator.Activate(subject);

            subject.Services.ShouldBeTheSameAs(services);
        }
Exemple #33
0
        public void race_condition()
        {
            var settings = new SchemaMetadataSettings
            {
                Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Clarify", "Metadata", SchemaMetadataSettings.FileName)
            };

            var visitors = new List <IXElementVisitor> {
                new ParseTables(), new ParseFields()
            };
            var service  = new XElementService(visitors);
            var services = new InMemoryServiceLocator();

            services.Add <IXElementService>(service);
            services.Add <IXElementSerializer>(new XElementSerializer());

            var cache = new SchemaMetadataCache(settings, new NulloLogger(), service, services);

            // Other tables shouldn't exist but will never be null
            cache.MetadataFor("test").ShouldNotBeNull();

            const string targetTable = "TEST_TABLE";
            var          actions     = new List <Action>();
            var          cleanups    = new List <Action>();

            for (var i = 0; i < 500; i++)
            {
                var thread = new Thread(() =>
                {
                    cache.MetadataFor("case1");
                    cache.MetadataFor("case1");
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                });

                actions.Add(() =>
                {
                    Thread.Sleep(50);
                    thread.Start();
                });

                cleanups.Add(() => thread.Join());
            }

            Parallel.Invoke(actions.ToArray());

            cleanups.Each(callback => callback());

            cache.MetadataFor(targetTable).ShouldNotBeNull();
        }
        private IDictionary <string, object> project(Projection <Party> projection)
        {
            var node     = new DictionaryMediaNode();
            var services = new InMemoryServiceLocator();

            services.Add(new HeroRepository());

            var context = new ProjectionContext <Party>(services, theParty);

            projection.As <IProjection <Party> >().Write(context, node);

            return(node.Values);
        }
        public void SetUp()
        {
            theRequest = ElementRequest.For<Address>(x => x.Address1);
            theAddress = new Address{
                Address1 = "22 Cherry Tree Lane"
            };

            var services = new InMemoryServiceLocator();
            services.Add(new Stringifier());
            theRequest.Attach(services);

            theRequest.Model = theAddress;
        }
Exemple #36
0
        public static IObjectBlockReader Reader()
        {
            var registry = new BindingRegistry();
            registry.Add(new VersionConstraintConverter());
            registry.Add(new GroupedDependencyConverter());

            var services = new InMemoryServiceLocator();
            var resolver = new ObjectResolver(services, registry, new NulloBindingLogger());

            services.Add<IObjectResolver>(resolver);

            return new ObjectBlockReader(new ObjectBlockParser(), resolver, services, new RippleBlockRegistry());
        }
        public void SetUp()
        {
            theRequest = ElementRequest.For<FieldValidationModifierTarget>(x => x.Name);
            theModifier = new FieldValidationElementModifier();
            theFieldModifier = MockRepository.GenerateStub<IFieldValidationModifier>();

            theRequest.ReplaceTag(new HtmlTag("input"));

            theServices = new InMemoryServiceLocator();
            theServices.Add(ValidationGraph.BasicGraph());
            theServices.Add(theFieldModifier);

            theRequest.Attach(theServices);
        }
Exemple #38
0
        public void SetUp()
        {
            var locator         = new InMemoryServiceLocator();
            var objectConverter = new ObjectConverter(locator, new ConverterLibrary(new[] { new StatelessComplexTypeConverter() }));

            locator.Add <IObjectConverter>(objectConverter);

            var converter = new ComplexTypeConverter(objectConverter);

            theInput      = "{\"Name\":\"Test\",\"Child\":\"x:123\"}";
            theSerializer = new NewtonSoftJsonSerializer(new JsonSerializerSettings(), new[] { converter });

            theObject = theSerializer.Deserialize <ParentType>(theInput);
        }
Exemple #39
0
        public void can_register_and_use_a_service_for_the_conversion()
        {
            var locator = new InMemoryServiceLocator();

            locator.Add <WidgetFinderService>(new WidgetFinderService());

            var library = new ConverterLibrary();

            finder = new ObjectConverter(locator, library);

            library.RegisterConverter <Widget, WidgetFinderService>((service, text) => service.Build(text));

            finder.FromString <Widget>("red").ShouldBeOfType <Widget>().Color.ShouldEqual("red");
        }
        public void SetUp()
        {
            theRequest = ElementRequest.For <Address>(x => x.Address1);
            theAddress = new Address {
                Address1 = "22 Cherry Tree Lane"
            };

            var services = new InMemoryServiceLocator();

            services.Add(new Stringifier());
            theRequest.Attach(services);

            theRequest.Model = theAddress;
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theScriptLog = new InMemoryScriptLog();
            theLocalVars = new SimpleDictionary<string, string>();

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IScriptLog>(theScriptLog);

            theScriptContext = new ScriptContext("1", "unvar", CancellationToken.None, theServices, theLocalVars);
            theHandler = new UnVarTokenHandler();
        }
Exemple #42
0
        private IServiceLocator services()
        {
            var rules = new AccessorRules();

            var overrides = new AccessorRulesValidationOverrides();

            overrides.As <IAccessorRulesRegistration>().AddRules(rules);

            var services = new InMemoryServiceLocator();

            services.Add(rules);

            return(services);
        }
Exemple #43
0
        public void SetUp()
        {
            theRequest       = ElementRequest.For <FieldValidationModifierTarget>(x => x.Name);
            theModifier      = new FieldValidationElementModifier();
            theFieldModifier = MockRepository.GenerateStub <IFieldValidationModifier>();

            theRequest.ReplaceTag(new HtmlTag("input"));

            theServices = new InMemoryServiceLocator();
            theServices.Add(ValidationGraph.BasicGraph());
            theServices.Add(theFieldModifier);

            theRequest.Attach(theServices);
        }
Exemple #44
0
        public static BlockWritingContext ContextFor <T>(Expression <Func <T, object> > expression, object subject = null)
        {
            var property = ReflectionHelper.GetProperty(expression);

            var services = new InMemoryServiceLocator();

            services.Add <IDisplayFormatter>(new DisplayFormatter(services, new Stringifier()));

            var context = new BlockWritingContext(services, ObjectBlockWriter.Basic(), BlockRegistry.Basic(), subject);

            context.StartProperty(property);

            return(context);
        }
        public void determine_the_mode_uses_the_default_when_no_policies_match()
        {
            var accessor = SingleProperty.Build<ValidationModeTarget>(x => x.Property);
            var services = new InMemoryServiceLocator();
            services.Add(new AccessorRules());

            var p1 = MockRepository.GenerateStub<IValidationModePolicy>();
            p1.Stub(x => x.Matches(services, accessor)).Return(false);
            p1.Stub(x => x.DetermineMode(services, accessor)).Return(ValidationMode.Triggered);

            var node = new ValidationNode();
            node.DefaultMode(ValidationMode.Live);
            node.RegisterPolicy(p1);

            node.As<IValidationNode>().DetermineMode(services, accessor).ShouldEqual(ValidationMode.Live);
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theScriptLog = new InMemoryScriptLog();
            theCommandProcessor = new StubCommandProcessor();

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IScriptLog>(theScriptLog);
            theServices.Add<ICommandProcessor>(theCommandProcessor);

            theScriptContext = new ScriptContext("1", "gototoken", CancellationToken.None, theServices, null);
            theScriptContext.DebugLevel = 5;
            theHandler = new GotoTokenHandler();
        }
        public void SetUp()
        {
            theServices = new InMemoryServiceLocator();
            theSearch = ChainSearch.ByUniqueInputType(typeof (object));
            theInput = new object();

            theResolver = MockRepository.GenerateStub<IChainResolver>();
            theUrlResolver = MockRepository.GenerateStub<IChainUrlResolver>();

            theChain = new BehaviorChain();

            theServices.Add(theResolver);
            theServices.Add(theUrlResolver);

            theRequest = new FormRequest(theSearch, theInput);
        }
        public void StringValue_delegates_to_Stringifier()
        {
            var stringifier = new Stringifier();

            stringifier.AddStrategy(new StringifierStrategy{
                Matches = r => true,
                StringFunction = r => "*" + r.RawValue + "*"
            });

            var services = new InMemoryServiceLocator();
            services.Add(stringifier);
            services.Add<IDisplayFormatter>(new DisplayFormatter(services, stringifier));

            var request = ElementRequest.For<Model1>(new Model1{Child = new Model2{Name = "Little Lindsey"}}, x => x.Child.Name);
            request.Attach(services);

            request.StringValue().ShouldEqual("*Little Lindsey*");
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theGameStream = new GameStream(theGameState);

            theGameState.Set(ComponentKeys.Roundtime, "0");

            theLog = new InMemoryScriptLog();

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IScriptLog>(theLog);

            theScriptContext = new ScriptContext("1", "waitfor", CancellationToken.None, theServices, null);
            theScriptContext.DebugLevel = 5;

            theHandler = new WaitForReTokenHandler(theGameState, theGameStream);
        }
        public void SetUp()
        {
            theModifier = new RemoteValidationElementModifier();
            theTag = new HtmlTag("input");

            theRequest = ElementRequest.For<RemoteTarget>(x => x.Username);
            theRequest.ReplaceTag(theTag);

            theRemoteGraph = new RemoteRuleGraph();
            theRemoteRule = theRemoteGraph.RegisterRule(theRequest.Accessor, new UniqueUsernameRule());

            theUrls = new StubUrlRegistry();

            theServices = new InMemoryServiceLocator();
            theServices.Add(theRemoteGraph);
            theServices.Add(theUrls);

            theRequest.Attach(theServices);
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theLogger = new InMemoryScriptLog();
            theGameStream = new GameStream(theGameState);

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLogger);
            theServices.Add<IVariableReplacer>(new VariableReplacer());
            theServices.Add<ICommandProcessor>(new CommandProcessor(theServices, theServices.Get<IVariableReplacer>(), theLogger));
            theServices.Add<IGameStream>(theGameStream);

            theScriptContext = new ScriptContext("1", "sendcommand", CancellationToken.None,  theServices, null);
            theScriptContext.DebugLevel = 5;

            theHandler = new SendCommandTokenHandler();
        }
Exemple #52
0
        public void displays_string_value_inside_of_a_span()
        {
            var stringifier = new Stringifier();

            stringifier.AddStrategy(new StringifierStrategy
            {
                Matches = r => true,
                StringFunction = r => "*" + r.RawValue + "*"
            });

            var services = new InMemoryServiceLocator();
            services.Add(stringifier);
            services.Add<IDisplayFormatter>(new DisplayFormatter(services, stringifier));

            var request = ElementRequest.For<ElementRequestTester.Model1>(new ElementRequestTester.Model1 { Child = new ElementRequestTester.Model2 { Name = "Little Lindsey" } }, x => x.Child.Name);
            request.Attach(services);
            request.ElementId = "something";

            var tag = new SpanDisplayBuilder().Build(request);
            tag.ToString().ShouldEqual("<span id=\"something\">*Little Lindsey*</span>");
        }
        public void SetUp()
        {
            inMemoryServiceLocator = new InMemoryServiceLocator();

            _binder = new EditEntityModelBinder(new NulloEntityDefaults());

            theGuid = Guid.NewGuid();

            theData = new InMemoryRequestData();
            theData["BobName"] = "Ryan";
            theData["Flavor"] = "choco";
            theData["Id"] = theGuid.ToString();

            cl = new ConverterLibrary();

            oc = new ObjectConverter(inMemoryServiceLocator, cl);

            inMemoryServiceLocator.Add<IObjectConverter>(oc);

            inMemoryServiceLocator.Add<IObjectResolver>(ObjectResolver.Basic());
        }
        public void SetUp()
        {
            theScript = new StubScript();
            theLoader = new StubScriptLoader();
            theLogger = new InMemoryScriptLog();

            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);

            theReplacer = new VariableReplacer();

            theServices = new InMemoryServiceLocator();

            theGameStream = new GameStream(theGameState);

            var waitForTokenHandler = new WaitForTokenHandler(theGameState, theGameStream);
            var waitForReTokenHandler = new WaitForReTokenHandler(theGameState, theGameStream);
            var matchWaitTokenHandler = new MatchWaitTokenHandler(theGameState, theGameStream);

            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLogger);
            theServices.Add<ICommandProcessor>(new CommandProcessor(theServices, theReplacer, theLogger));
            theServices.Add<IVariableReplacer>(theReplacer);
            theServices.Add<IIfBlocksParser>(new IfBlocksParser());
            theServices.Add<WaitForTokenHandler>(waitForTokenHandler);
            theServices.Add<WaitForReTokenHandler>(waitForReTokenHandler);
            theServices.Add<MatchWaitTokenHandler>(matchWaitTokenHandler);
            theServices.Add<IIfBlockExecuter>(new IfBlockExecuter(waitForTokenHandler, waitForReTokenHandler, matchWaitTokenHandler));

            theRunner = new ScriptRunner(theServices, theLoader, theLogger);

            theRunner.Create = () => theScript;
        }
Exemple #55
0
        public void SetUp()
        {
            theLog = new InMemoryScriptLog();
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theGameStream = new GameStream(theGameState);

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLog);
            theServices.Add<IVariableReplacer>(new VariableReplacer());
            theServices.Add<ICommandProcessor>(new CommandProcessor(theServices, theServices.Get<IVariableReplacer>(), theLog));
            theServices.Add<IIfBlocksParser>(new IfBlocksParser());
            var waitFor = new WaitForTokenHandler(theGameState, theGameStream);
            var waitForRe = new WaitForReTokenHandler(theGameState, theGameStream);
            var matchWait = new MatchWaitTokenHandler(theGameState, theGameStream);
            theServices.Add<WaitForTokenHandler>(waitFor);
            theServices.Add<WaitForReTokenHandler>(waitForRe);
            theServices.Add<MatchWaitTokenHandler>(matchWait);
            theServices.Add<IIfBlockExecuter>(new IfBlockExecuter(waitFor, waitForRe, matchWait));
            theServices.Add<IGameStream>(theGameStream);

            theScript = new Script(theServices, Tokenizer.With(TokenDefinitionRegistry.Default()));
        }
Exemple #56
0
 public void SetUp()
 {
     stringifier = new Stringifier();
     locator = new InMemoryServiceLocator();
 }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);

            theVariableReplacer = new VariableReplacer();
            theGameStream = new GameStream(theGameState);

            theScriptLog = new InMemoryScriptLog();

            theRunner = new StubScriptRunner();
            theServices = new InMemoryServiceLocator();

            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptRunner>(theRunner);
            theServices.Add<IVariableReplacer>(theVariableReplacer);
            theServices.Add<IGameStream>(theGameStream);

            theProcessor = new CommandProcessor(theServices, theVariableReplacer, theScriptLog);
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theLogger = new InMemoryScriptLog();
            theCancelSource = new CancellationTokenSource();

            theGameState.Set(ComponentKeys.Roundtime, "0");

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLogger);

            theScriptContext = new ScriptContext("1", "pausetoken", theCancelSource.Token, theServices, null);

            theHandler = new PauseTokenHandler();
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);

            theGameState.Set(ComponentKeys.Roundtime, "0");

            theLog = new InMemoryScriptLog();

            theReplacer = new VariableReplacer();
            theGameStream = new GameStream(theGameState);

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLog);
            theServices.Add<IVariableReplacer>(theReplacer);
            theServices.Add<IIfBlockExecuter>(
                new IfBlockExecuter(
                    new WaitForTokenHandler(theGameState, theGameStream),
                    new WaitForReTokenHandler(theGameState, theGameStream),
                    new MatchWaitTokenHandler(theGameState, theGameStream)
                ));
            theServices.Add<IGameStream>(theGameStream);

            theCommandProcessor = new CommandProcessor(theServices, theReplacer, theLog);
            theServices.Add<ICommandProcessor>(theCommandProcessor);

            theLocalVars = new SimpleDictionary<string, string>();

            theScriptContext = new ScriptContext("1", "if", CancellationToken.None, theServices, theLocalVars);
            theScriptContext.DebugLevel = 5;

            theHandler = new IfTokenHandler();
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theScriptLog = new InMemoryScriptLog();
            theCommandProcessor = new StubCommandProcessor();

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IScriptLog>(theScriptLog);
            theServices.Add<ICommandProcessor>(theCommandProcessor);

            theLocalVars = new SimpleDictionary<string, string>();

            theScriptContext = new ScriptContext("1", "containsre", CancellationToken.None, theServices, theLocalVars);
            theScriptContext.DebugLevel = 5;
            theHandler = new ContainsReTokenHandler();
        }