Esempio n. 1
0
        public void TestMethod1()
        {
            var config = @"
{
    fullname: {
        Format: ""{0} {1} {2}"",
        Args: [
            ""lastname"",
            ""firstname"",
            ""middlename"",
        ]
    }
}";
            var entity = new Entity("contact", Guid.NewGuid())
            {
                ["firstname"]  = "РОМАН",
                ["lastname"]   = "копаев-ЗаДуНайский",
                ["middlename"] = "анатольевич"
            };
            IPluginExecutionContext context         = new FakePluginExecutionContext(entity);
            IServiceProvider        serviceProvider = new FakeServiceProvider(context);

            var plugin = new Format(config);

            plugin.Execute(serviceProvider);
            var result = context.GetContextEntity();

            Assert.AreEqual("копаев-ЗаДуНайский РОМАН анатольевич", result["fullname"]);
        }
        public void SimpleData()
        {
            var entity = new Entity("contact", Guid.NewGuid())
            {
                ["quote"] = "никогда НЕ быЛО, И ВОТ опЯть!"
            };
            IPluginExecutionContext context         = new FakePluginExecutionContext(entity);
            IServiceProvider        serviceProvider = new FakeServiceProvider(context);

            var plugin = new ToFirstTitleCase(CONFIG_STR);

            plugin.Execute(serviceProvider);

            var result = context.GetContextEntity();

            Assert.AreEqual("Никогда НЕ быЛО, И ВОТ опЯть!", result["quote"]);
        }
        public void PartialData()
        {
            var entity = new Entity("contact", Guid.NewGuid())
            {
                ["firstname"]  = "рОМАН",
                ["middlename"] = "анатольевич"
            };
            IPluginExecutionContext context         = new FakePluginExecutionContext(entity);
            IServiceProvider        serviceProvider = new FakeServiceProvider(context);

            var plugin = new ToTitleCase(CONFIG_STR);

            plugin.Execute(serviceProvider);

            var result = context.GetContextEntity();

            Assert.AreEqual("Роман", result.GetAttributeValue <string>("firstname"));
            Assert.IsNull(result.GetAttributeValue <string>("lastname"));
            Assert.AreEqual("Анатольевич", result.GetAttributeValue <string>("middlename"));
        }
        public void SimpleData()
        {
            var entity = new Entity("contact", Guid.NewGuid())
            {
                ["firstname"]  = "РОМАН",
                ["lastname"]   = "копаев-ЗаДуНайский",
                ["middlename"] = "анатольевич"
            };
            IPluginExecutionContext context         = new FakePluginExecutionContext(entity);
            IServiceProvider        serviceProvider = new FakeServiceProvider(context);

            var plugin = new ToUpperCase(CONFIG_STR);

            plugin.Execute(serviceProvider);

            var result = context.GetContextEntity();

            Assert.AreEqual("РОМАН", result["firstname"]);
            Assert.AreEqual("КОПАЕВ-ЗАДУНАЙСКИЙ", result["lastname"]);
            Assert.AreEqual("АНАТОЛЬЕВИЧ", result["middlename"]);
        }
Esempio n. 5
0
        public void ServiceProviderBuilder_WithContext_GivenContext_Should_ReturnClonedContext()
        {
            //
            // Arrange
            //
            var context = new FakePluginExecutionContext();

            context.SharedVariables.Add("TEST", 1);
            var provider = new ServiceProviderBuilder(null, null).
                           WithContext(context).Build();

            //
            // Act
            //
            var providerContext = (IPluginExecutionContext)provider.GetService(typeof(IPluginExecutionContext));

            //
            // Assert
            //
            Assert.IsFalse(ReferenceEquals(providerContext, context), "The Context Retrieved should have been the context set");
            Assert.AreEqual(providerContext.GetFirstSharedVariable <int>("TEST"), 1);
        }
Esempio n. 6
0
 protected PluginExecutionContextBuilderBase()
 {
     Context = new FakePluginExecutionContext();
 }