public void PerformanceTest()
        {
            CSharpScriptTransform transform = new CSharpScriptTransform();

            transform.ScriptText = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Lithnet.Transforms;
using Microsoft.MetadirectoryServices;

public static class CSExtension
{
    public static IList<object> Transform(IList<object> obj)
    {
        return new List<object>() { obj.First() };        
    }
}";

            UnitTestControl.PerformanceTest(() =>
            {
                Assert.AreEqual("1", transform.TransformValue("1").First());
            }, 130000);
        }
        public void TestMV()
        {
            CSharpScriptTransform transform = new CSharpScriptTransform();

            transform.ScriptText = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Lithnet.Transforms;
using Microsoft.MetadirectoryServices;

public static class CSExtension
{
    public static IList<object> Transform(IList<object> obj)
    {
        return obj;       
    }
}";
            IList <object> results = transform.TransformValue(new List <object>()
            {
                "1", "2"
            });

            Array expected = new List <object>()
            {
                "1", "2"
            }.ToArray();

            CollectionAssert.AreEqual(expected, results.ToArray());
        }
        public void TestDeclineMapping()
        {
            CSharpScriptTransform transform = new CSharpScriptTransform();

            transform.ScriptText = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Lithnet.Transforms;
using Microsoft.MetadirectoryServices;

public static class CSExtension
{
    public static IList<object> Transform(IList<object> obj)
    {
        throw new DeclineMappingException();    
    }
}";
            try
            {
                IList <object> results = transform.TransformValue(new List <object>()
                {
                    "1", "2"
                });
                Assert.Fail("The expected exception was not thrown");
            }
            catch (DeclineMappingException)
            {
            }
        }
Esempio n. 4
0
 public CSharpScriptTransformViewModel(CSharpScriptTransform model)
     : base(model)
 {
     this.model = model;
     if (this.model.ScriptText == null)
     {
         this.SeDefaultScriptText();
     }
 }