Beispiel #1
0
        public NMockitoInstance()
        {
            Instance = this;

            proxyGenerator = new ProxyGenerator();
            invocationDescriptorFactory = new InvocationDescriptorFactory();
            IReadOnlyList <InvocationTransformation> transformations = new InvocationTransformation[] {
                new OutEnablingInvocationTransformationImpl(),
                new UnwrapParamsInvocationTransformationImpl(),
                new CreateImplicitEqualitySmartParametersInvocationTransformationImpl()
            };

            invocationTransformer = new InvocationTransformer(transformations);
            var verificationInvocationsContainer = new VerificationInvocationsContainer();

            invocationStage = new InvocationStage(verificationInvocationsContainer);
            invocationOperationManagerFinder = new InvocationOperationManagerFinder();
            mockFactory            = new MockFactoryImpl(proxyGenerator, invocationDescriptorFactory, invocationTransformer, invocationStage, invocationOperationManagerFinder);
            smartParameterStore    = new SmartParameterStore();
            smartParameterPusher   = new SmartParameterPusher(smartParameterStore);
            assertionsProxy        = new AssertionsProxy();
            expectationFactory     = new ExpectationFactory(invocationStage, invocationOperationManagerFinder, verificationInvocationsContainer);
            verificationOperations = new VerificationOperations(invocationStage, verificationInvocationsContainer);
            ExceptionCaptorFactory exceptionCaptorFactory = new ExceptionCaptorFactory(proxyGenerator);

            fluentExceptionAssertor = new FluentExceptionAssertor(exceptionCaptorFactory);
            VerificationMockFactory verificationMockFactory = new VerificationMockFactory(proxyGenerator);

            verificationOperationsProxy = new VerificationOperationsProxy(invocationStage, verificationOperations, verificationMockFactory);
            placeholderFactory          = new PlaceholderFactory(mockFactory);
        }
Beispiel #2
0
        public static TValue Create <TParam1, TValue>(this PlaceholderFactory <TParam1, TValue> factory, TParam1 p1, Transform parent)
            where TValue : Component
        {
            var value = factory.Create(p1);

            if (parent != null)
            {
                value.transform.SetParent(parent, false);
            }

            return(value);
        }
Beispiel #3
0
        internal List <PlaceholderModel> Parse(string hudOptionsPath)
        {
            int xmlVersion = GetXmlVersion(hudOptionsPath);

            if (xmlVersion < CURRENT_XML_VERSION)
            {
                UpdateXmlVersion(xmlVersion, hudOptionsPath);
            }

            Dictionary <string, PlaceholderModel> placeHolders = new Dictionary <string, PlaceholderModel>();

            string fileContent = File.ReadAllText(hudOptionsPath);

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(fileContent)))
            {
                while (xmlReader.ReadToFollowing("name"))
                {
                    string name = xmlReader.ReadElementContentAsString();

                    if (!IsGeometricItem(name))
                    {
                        continue;
                    }

                    GeometricItem item = GetGeometricItem(name);

                    if (blackList.IsFiltered(item.Name))
                    {
                        continue;
                    }

                    if (!placeHolders.ContainsKey(item.Name))
                    {
                        PlaceholderModel placeholder = PlaceholderFactory.NewPlaceholder(item.Name);
                        placeHolders.Add(placeholder.Name, placeholder);
                    }

                    xmlReader.ReadToFollowing("value");

                    xmlReader.MoveToFirstAttribute();
                    string valueType = xmlReader.Value;

                    if (valueType != ValueType.VECTOR)
                    {
                        throw new Exception($"Expected value is a {ValueType.VECTOR}");
                    }

                    xmlReader.MoveToContent();
                    string value = xmlReader.ReadElementContentAsString();

                    switch (item.ItemType)
                    {
                    case ItemType.POSITION:
                        placeHolders[item.Name].Position = ParseVector(value);
                        break;

                    case ItemType.SIZE:
                        placeHolders[item.Name].Size = ParseVector(value);
                        break;

                    case ItemType.ANCHOR:
                        placeHolders[item.Name].Anchor = ParseVector(value);
                        break;
                    }
                }
            }

            return(placeHolders.Values.ToList());
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            IPlaceholderContext  placeholderContext  = new PlaceholderContext();
            IPlaceholderFactory  placeholderFactory  = new PlaceholderFactory();
            IPlaceholderRegister placeholderRegister = new PlaceholderRegister(placeholderContext, placeholderFactory);

            List <User> fakeUserTable = new List <User>
            {
                new User {
                    Id = 1, Name = "Miro", LastName = "Mirić", OIB = "12121212-1"
                },
                new User {
                    Id = 2, Name = "Miro2", LastName = "Mirić2", OIB = "12121212-2"
                },
                new User {
                    Id = 3, Name = "Miro3", LastName = "Mirić3", OIB = "12121212-3"
                },
                new User {
                    Id = 4, Name = "Miro4", LastName = "Mirić4", OIB = "12121212-4"
                },
                new User {
                    Id = 5, Name = "Miro5", LastName = "Mirić5", OIB = "12121212-5"
                },
            };
            List <Address> fakeAdressTable = new List <Address>
            {
                new Address {
                    Id = 1, AddressName = "a1", userId = 1
                },
                new Address {
                    Id = 2, AddressName = "a2", userId = 1
                },
                new Address {
                    Id = 3, AddressName = "a3", userId = 2
                },
                new Address {
                    Id = 4, AddressName = "a4", userId = 2
                },
                new Address {
                    Id = 5, AddressName = "a5", userId = 3
                },
            };

            //set data
            placeholderContext.UserId    = 1;
            placeholderContext.Users     = fakeUserTable;
            placeholderContext.Addresses = fakeAdressTable;



            //All replacing should be specified here
            //Problem: possibly to many data

            string testInput = "I am [[last_name_placeholder]], [[name_placeholder]] [[last_name_placeholder]].";

            testInput = testInput.Replace("[[name_placeholder]]", placeholderRegister.GetNamePlaceholder(placeholderContext.UserId));
            testInput = testInput.Replace("[[last_name_placeholder]]", placeholderRegister.GetLastNamePlaceholder(placeholderContext.UserId));
            testInput = testInput.Replace("[[oib_placeholder]]", placeholderRegister.GetOIBPlaceholder(placeholderContext.UserId));


            Console.WriteLine(testInput);

            Console.ReadKey();
        }
 public DefaultEnemyGenerator(Pursuer.Factory pursuerFactory, PlayerAdvancedPursuer.Factory advancedPursuerFactory)
 {
     this.pursuerFactory         = pursuerFactory;
     this.advancedPursuerFactory = advancedPursuerFactory;
 }