public void DecorateClass()
        {
            var targetObj = new TargetObjImpl();
            var proxy     = decorator.Decorate(targetObj);

            Assert.That(proxy, Is.SameAs(targetObj.Self));
            Assert.That(1, Is.EqualTo(proxy.DoSomething()));
            Assert.That(1, Is.EqualTo(countAspect.CallCount));
        }
Exemple #2
0
        public void TestMethod1()
        {
            var actualText     = "this is a test.";
            var subText        = "this test";
            var expectedResult = "<span>this</span> is a <span>test</span>.";

            var decoratedText = _decorator.Decorate(actualText, subText);

            Assert.AreEqual(expectedResult, decoratedText);
        }
        public void GetPropertyInfoProp()
        {
            // Regression test for (internal). Use a decorated factory since
            // propertyInfo.pProperty should be the decorated object.
            var decoratorUtil = new DecoratorUtil(
                new ProxyGenerationOptions(new DebugEngineProxyHook()));

            // Needs at least one aspect or else decorator is not assigned to Self.
            IDecorator factoryDecorator = decoratorUtil.CreateFactoryDecorator(
                new ProxyGenerator(), new NoopAspect());

            DebugAsyncProperty.Factory decoratedPropertyFactory =
                factoryDecorator.Decorate(propertyFactory);

            IGgpAsyncDebugProperty decoratedDebugProperty =
                decoratedPropertyFactory.Create(mockVarInfo);

            DEBUG_PROPERTY_INFO propertyInfo;

            decoratedDebugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP,
                                                   out propertyInfo);

            Assert.That(
                propertyInfo.dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP));

            Assert.That(propertyInfo.pProperty, Is.SameAs(decoratedDebugProperty));
        }
Exemple #4
0
        public void ShouldSetSelfWhenDecorating()
        {
            var targetObj = new TargetObjImpl();

            var proxy = (TargetObjImpl)classUnderTest.Decorate(typeof(TargetObjImpl), targetObj);

            Assert.AreSame(targetObj.Self, proxy);
        }
Exemple #5
0
 public static void Decorate(Chunk chunk, double[,] terrainHeightMap, OverworldNoise noise)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             var        b         = ChunkBiome.GetBiome((chunk.X << 4) + x, (chunk.Z << 4) + z, noise);
             IDecorator decorator = DecoratorFactory.GetDecorator(b);
             var        blockPos  = new Vector(x, (int)terrainHeightMap[x, z], z);
             decorator.Decorate(chunk, blockPos, noise);
         }
     }
 }
Exemple #6
0
        public static void Decorate(Chunk chunk, double[,] terrainHeightMap, OverworldTerrain ot, World world)
        {
            var noise = new TerrainNoise(ot.settings);

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    var        b         = ChunkBiome.GetBiome((chunk.X << 4) + x, (chunk.Z << 4) + z, ot);
                    var        blockPos  = new Vector(x, (int)terrainHeightMap[x, z], z);
                    IDecorator decorator = DecoratorFactory.GetDecorator(b, chunk, blockPos, noise);
                    decorator.Decorate();
                    GenerateTrees(world, blockPos + (chunk.X << 4, 0, chunk.Z << 4), decorator.Features, noise);
                }
            }
        }
Exemple #7
0
 public Task <bool> APIErrorLogger(Guid runId, string error)
 {
     return(_docerator.Decorate <bool>(() =>
     {
         bool ret = false;
         using (var dbContext = new PerformanceDbContext())
         {
             var master = dbContext.PerformanceExecutions.FirstOrDefault(m => m.RunId == runId);
             if (string.IsNullOrEmpty(error) || master == null)
             {
                 return false;
             }
             var errorLog = new APIErrorLog()
             {
                 RunId = runId,
                 PerformanceExecution = master,
                 Error = error,
             };
             dbContext.APIErrorLogs.Add(errorLog);
             ret = dbContext.SaveChanges() > 0;
         }
         return ret;
     }));
 }
Exemple #8
0
 public static void Decoration <T>(IDecorator <T> a, Action <T> b)
 {
     a.Decorate(b);
 }
 public void Execute()
 {
     decorator.Decorate(Fig, text);
 }
Exemple #10
0
 /// <summary>
 /// Convenience function that delegates to Decorate(Type, object).
 /// </summary>
 public static T Decorate <T>(this IDecorator decorator, T obj) where T : class
 {
     return((T)decorator.Decorate(typeof(T), obj));
 }
 public object Decorate(Type type, object obj)
 {
     decorator.Decorate(type, obj);
     return(obj);
 }