コード例 #1
0
        public ActionResult Game()
        {
            BullsAndCows.Generator.Generator generator = new Generator.Generator();
            BullsAndCows.Models.Give         give      = new Models.Give();

            int[] a = new int[5];
            a = generator.GeneratorRand();
            give.GenNumber = a;


            if (Session["Const"] == null)
            {
                Session["Const"] = 0;
            }
            Session["Const"] = a;

            if (Session["BullAndCow"] == null)
            {
                Session["BullAndCow"] = 0;
            }

            int[,] massBullAndCow = new int[3, 30];

            Session["BullAndCow"] = massBullAndCow;

            give.InNumber = 0;
            return(View(give));
        }
コード例 #2
0
        public void GetProductsTest()
        {
            // Arrange

            // PM> Install-Package Microsoft.EntityFrameworkCore.InMemory
            var options = new DbContextOptionsBuilder <ShopContext>()
                          .UseInMemoryDatabase(databaseName: "getproducts")
                          .Options;

            using (var context = new ShopContext(options))
            {
                Generator.Generator generator = new Generator.Generator();
                context.Products.AddRange(generator.GetProducts(100));
                context.SaveChanges();
            }

            using (var context = new ShopContext(options))
            {
                IProductsService productsService = new DbProductsService(context);

                // Acts
                var products = productsService.Get();

                // Asserts
                Assert.NotEmpty(products);

                // PM> Install-Package FluentAssertions

                products.Should().NotBeNullOrEmpty();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: baristikir/CodeGenerator
 private static bool StartProcess(string filePath_Model, string filePath_Output)
 {
     Reader.Reader       reader    = new Reader.Reader(filePath_Model);
     Datamodel.Datamodel datamodel = reader.getDatamodel();
     Generator.Generator generator = new Generator.Generator(filePath_Output, datamodel);
     return(generator.generateCode());
 }
コード例 #4
0
        private void ListMethods()
        {
            var inputBaseFolder = new Uri(Path.GetDirectoryName(IdlFilename) + "\\", UriKind.Absolute);
            var configBuilder   = CreateConfigBuilder(inputBaseFolder, Path.GetTempPath());
            var input           = new Uri(IdlFilename, UriKind.Absolute);

            try
            {
                _codeGenerator = new OCGenerator(configBuilder.Build());
                var contexts = _codeGenerator.GetContexts(input);
                var service  = ContextUtils.ExtractService(contexts[contexts.Count - 1]);
                if (service != null)
                {
                    m_PrunerPanel.Service = service;
                }
                else
                {
                    m_GenerateGroupBox.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Code generation failed: " + ex.Message, Resources.ProductName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        public void GetProductsTest()
        {
            //arrange
            var options = new DbContextOptionsBuilder <ShopContext>()
                          .UseInMemoryDatabase(databaseName: "getproducts")
                          .Options;

            using (var context = new ShopContext(options))
            {
                Generator.Generator generator = new Generator.Generator();
                context.Products.AddRange(generator.GetProducts(100));
                context.SaveChanges();
            }
            using (var context = new ShopContext(options))
            {
                IProductsService productsService = new DbProductsService(context);

                //acts
                var products = productsService.Get();

                //asserts
                Assert.NotEmpty(products);

                products.Should().NotBeNullOrEmpty();
            }
        }
コード例 #6
0
        public void DistributedTransactionsTest()
        {
            var options = new DbContextOptionsBuilder <ShopContext>()
                          .UseInMemoryDatabase(databaseName: "getproducts")
                          .Options;


            Generator.Generator generator = new Generator.Generator();

            using (var transactionScope = new TransactionScope())
            {
                using (var context1 = new ShopContext(options))
                {
                    context1.Products.AddRange(generator.GetProducts(50));
                    context1.SaveChanges();
                }

                using (var context2 = new ShopContext(options))
                {
                    context2.Products.AddRange(generator.GetProducts(10));
                    context2.SaveChanges();
                }

                transactionScope.Complete();
            }
        }
コード例 #7
0
        public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
        {
            Generator.Generator generator = new Generator.Generator();
            if (!ArithmeticUtils.CheckArithmetic(instruction))
            {
                return(null);
            }
            ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);

            return(new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Add), ArithmeticTypes));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: Crunchley/pocztowyentity
        private static void CreateSampleData(ShopContext context)
        {
            //generowanie danych
            Generator.Generator generator = new Generator.Generator();
            var products  = generator.GetProducts(100);
            var services  = generator.GetServices(100);
            var customers = generator.GetCustomers(10);

            context.Products.AddRange(products);
            context.Services.AddRange(services);
            context.Customers.AddRange(customers);
            context.SaveChanges();
        }
コード例 #9
0
 /// <summary>
 /// Erstellt Reader und Generator und führt deren Interface-Methoden aus.
 /// </summary>
 /// <param name="filePath_Model">Gibt dem Reader den Dateipfad mit.</param>
 /// <param name="filePath_Output">Gibt dem Generator den Ausgabepfad mit.</param>
 public Datamodel.Datamodel ExchangeData(string filePath_Model, string filePath_Output)
 {
     Reader.Reader       reader    = new Reader.Reader(filePath_Model);
     Datamodel.Datamodel datamodel = reader.getDatamodel();
     Generator.Generator generator = new Generator.Generator(filePath_Output, datamodel);
     if (generator.generateCode())
     {
         return(datamodel);
     }
     else
     {
         return(null);
     }
 }
コード例 #10
0
        public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
        {
            Generator.Generator generator = new Generator.Generator();
            if (!ArithmeticUtils.CheckArithmetic(instruction))
            {
                return(null);
            }
            List <ArithmeticTypes> arithmeticTypes = new List <ArithmeticTypes>()
            {
                ArithmeticTypes.Add, ArithmeticTypes.Sub
            };
            ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);

            return(new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
        }
コード例 #11
0
 private Invention TestExistence()
 {
     try
     {
         var g = new Generator.Generator(Noun, Modifiers, 1);
         return(g.Generate());
     }
     catch (CatSAT.ContradictionException)
     {
         return(null);
     }
     catch (CatSAT.TimeoutException)
     {
         return(null);
     }
 }
コード例 #12
0
        private void Generate()
        {
            Clear();

            Generator.Generator generator = new Generator.Generator(width, height, seed, waterLayers.ToModel(), biomesDiagram.ToModel(),
                                                                    waterNoiseMapParameters.ToModel(), heightNoiseMapParameters.ToModel(), temperatureNoiseMapParameters.ToModel());

            generator.Generate();
            Map = generator.Map;

            ISpaceOrientation spaceOrientation = new SpaceOrientationFactory().GetSpaceOrientation(orientationType);

            IGraphicalMapGenerator graphicalMapGenerator = new GraphicalMapGeneratorFactory().GetGraphicalMapGenerator(generationType, spaceOrientation);

            graphicalMapGenerator.Render(transform, generator.Map);

            ObjectsGenerator objectsGenerator = new ObjectsGenerator(spaceOrientation);

            objectsGenerator.Render(transform, generator.AwaitingObjects);
        }
コード例 #13
0
        private static void CreateOrderTest()
        {
            Console.WriteLine("Witaj w naszym sklepie!");

            Console.WriteLine("Podaj id klienta:");
            int customerId = int.Parse(Console.ReadLine());

            Console.WriteLine("Podaj id produktu:");
            int productId = int.Parse(Console.ReadLine());

            Console.WriteLine("Podaj ilość:");
            int quantity = int.Parse(Console.ReadLine());

            // TODO: pobrac klienta i produkt ze zrodla danych

            ICustomersService customersService = new FakeCustomersService();
            IItemsService     itemsService     = new FakeItemsService();

            // Przygotowanie danych
            Generator.Generator generator = new Generator.Generator();
            var customers = generator.GetCustomers(100);

            customersService.Add(customers);

            var products = generator.GetProducts(50);
            var services = generator.GetServices(50);

            // połączenie zbiorów
            var items = products.OfType <Item>().Concat(services).ToList();

            itemsService.Add(items);


            // Pobranie
            Customer customer = customersService.Get(customerId);
            Item     item     = itemsService.Get(productId);

            Order order = new Order("ZA 001", customer);

            order.Details.Add(new OrderDetail(item, quantity));
        }
コード例 #14
0
        public void NativeTransactionsTest()
        {
            var options = new DbContextOptionsBuilder <ShopContext>()
                          .UseInMemoryDatabase(databaseName: "getproducts")
                          .Options;

            Generator.Generator generator = new Generator.Generator();
            using (var context = new ShopContext(options))
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    context.Products.AddRange(generator.GetProducts(50));
                    context.SaveChanges();

                    context.Products.AddRange(generator.GetProducts(50));
                    context.SaveChanges();

                    transaction.Commit();
                }
            }
        }
コード例 #15
0
        public void NumBombsCorrect(
            [NUnit.Framework.Values(0u, 1u, 2u, 10u, 100u)] uint numBombs)
        {
            // Use the Assert class to test conditions
            Generator.Generator generator = new Generator.Generator();
            Board board = generator.Generate(10, 4, 8, numBombs, disableSolving: true);

            // count bombs
            uint bombSum = 0;

            foreach (BoardCell cell in board.Cells)
            {
                if (cell.IsBomb)
                {
                    bombSum++;
                }
            }

            if (numBombs <= 10 * 4 * 8)
            {
                Assert.AreEqual(numBombs, bombSum, "Wrong number of bombs in the board.");
            }
        }
コード例 #16
0
ファイル: Testing.cs プロジェクト: polina725/TestGenerator
 public void Init()
 {
     Generator.Generator gen = new Generator.Generator("..\\..\\..\\Output");
     generatedTests = gen.AnalyseFile(File.ReadAllText("..\\..\\..\\Input\\Exemple.cs"));
     root           = CSharpSyntaxTree.ParseText(generatedTests[1].SourceCode).GetRoot();
 }
コード例 #17
0
 public void NumBombsTooBig()
 {
     Generator.Generator generator = new Generator.Generator();
     Assert.Throws <ArgumentException>(() => { generator.Generate(10, 4, 8, 1001u); });
 }
コード例 #18
0
ファイル: GameScreen.cs プロジェクト: vadimprokop/Mastermind
 private void GenerateValues()
 {
     Generator.Generator generator = new Generator.Generator(4);
     generator.Generate();
     generatedValues = generator.GetGeneratedColor;
 }
コード例 #19
0
        public ActionResult Game(int InNumber)
        {
            BullsAndCows.Generator.Generator generator = new Generator.Generator();
            BullsAndCows.Models.Give         give      = new Models.Give();



            //генерируемое число
            int[] b = (int[])Session["Const"];
            give.GenNumber = b;

            //введенное число
            give.InNumber = InNumber;


            int bull = 0, cow = 0;


            int n = InNumber;

            //разбор введеного числа на массив
            int[]   nIn  = new int[5];
            int     del  = 10000;
            Boolean flag = false;

            for (int i = 0; i < 5; i++)
            {
                nIn[i] = n / del;
                for (int j = 0; j < i; j++)
                //проверка на повторение цифр
                {
                    if (nIn[i] == nIn[j])
                    {
                        flag = true;
                    }
                }

                n   = n - del * nIn[i];
                del = del / 10;
            }

            //Подсет коров и быков
            if (flag == false)
            {
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (nIn[i] == b[j])
                        {
                            if (i == j)
                            {
                                bull++;
                            }
                            else
                            {
                                cow++;
                            }
                        }
                    }
                }
            }
            else
            {
                cow  = 0;
                bull = 0;
            }

            give.InNumber         = InNumber;
            give.CoincidenceBulls = bull;
            give.CoincidenceCows  = cow;
            give.Flag             = flag;

            //массив для записи результатов

            int[,] massBullAndCow = (int[, ])Session["BullAndCow"];


            int freeMass = 0;

            if (InNumber != 0 && flag == false)
            {
                //ищем свободное место в массиве
                while (massBullAndCow[0, freeMass] != 0)
                {
                    freeMass++;
                }


                massBullAndCow[0, freeMass] = InNumber;
                massBullAndCow[1, freeMass] = bull;
                massBullAndCow[2, freeMass] = cow;
            }
            else
            {
                while (massBullAndCow[0, freeMass] != 0)
                {
                    freeMass++;
                }
            }

            Session["BullAndCow"] = massBullAndCow;

            give.BullAndCow = massBullAndCow;
            give.FreeMass   = freeMass;
            return(View(give));
        }