コード例 #1
0
        public void TestGenerateAllFiles_Folder_Sub_File()
        {
            IFile        staticFile   = mocks.DynamicMock <IFile>();
            IScript      scriptFile   = mocks.DynamicMock <IScript>();
            IFolder      subFolder    = mocks.DynamicMock <IFolder>();
            ProviderInfo providerMock = mocks.DynamicMock <ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(subFolder, new IFolder[0], new[] { scriptFile }, new[] { staticFile }, "folder");
                SetupFolder(folder, new[] { subFolder }, new IScript[0], new IFile[0], "");
                SetupProject();
                SetupStaticFile(staticFile);
                SetupScriptFile(scriptFile);
                SetupProvider(providerMock);
                SetupController();
                SetupLoader(scriptFile);
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "Class.cs", "C:\\Temp\\folder\\Class.cs", "folder\\Class.cs", "Class", "Iterator")));
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "file.jpg", "C:\\Temp\\folder\\file.jpg", "folder\\file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(3));
            ProjectFileTreeNode subfolder = tree.ChildNodes[0];

            Assert.That(subfolder.Status, Is.EqualTo(ProjectFileStatusEnum.Folder));
            Assert.That(subfolder.Text, Is.EqualTo("folder"));
            Assert.That(subfolder.ChildNodes.Count, Is.EqualTo(2));

            ProjectFileTreeNode childNode = subfolder.ChildNodes[0];

            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("Class.cs"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "Class.cs")));
            TextFileInformation tfi = (TextFileInformation)childNode.AssociatedFile;

            Assert.That(tfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");

            childNode = subfolder.ChildNodes[1];
            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("file.jpg"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "file.jpg")));
            BinaryFileInformation bfi = (BinaryFileInformation)childNode.AssociatedFile;

            Assert.That(bfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");

            mocks.VerifyAll();
        }
コード例 #2
0
        private void Generate(object sender, EventArgs a)
        {
            if (meetingNotes == null)
            {
                return;
            }

            var saveFileDialog = new FileChooserDialog("Save report as ...", this, FileChooserAction.Save,
                                                       "OK", ResponseType.Ok, "Cancel", ResponseType.Cancel);

            saveFileDialog.SetFilename("report.docx");

            var dialogResult = saveFileDialog.Run();

            saveFileDialog.Hide();

            if (dialogResult != (int)ResponseType.Ok)
            {
                return;
            }

            var filename = saveFileDialog.Filename;

            GenerationHelper.GenerateAndOpen(filename, meetingNotes);
        }
コード例 #3
0
        public void TestGenerateAllFiles_Static_File()
        {
            IFile        file         = mocks.DynamicMock <IFile>();
            ProviderInfo providerMock = mocks.DynamicMock <ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(folder, new IFolder[0], new IScript[0], new[] { file }, "");
                SetupProject();
                SetupLoader();
                SetupStaticFile(file);
                SetupProvider(providerMock);
                SetupController();
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "file.jpg", "C:\\Temp\\file.jpg", "file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(1));
            Assert.That(tree.AllNodes[0].Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(tree.AllNodes[0].Text, Is.EqualTo("file.jpg"));
            Assert.That(tree.ChildNodes[0].AssociatedFile.RelativeFilePath, Is.EqualTo("file.jpg"));
            BinaryFileInformation bfi = (BinaryFileInformation)tree.ChildNodes[0].AssociatedFile;

            Assert.That(bfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), tree.ChildNodes[0].AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");
            mocks.VerifyAll();
        }
コード例 #4
0
ファイル: CardService.cs プロジェクト: DimitriDondoladze/BBS
        public async Task GenerateCard(Account account, string type)
        {
            _logger.Info($"Genereated Card by name: {account.Name}");
            string cardIdentifier = GenerationHelper.GenerateIdentifier();
            int    timeSpan       = PropertyHelper.ValidSpanYears;
            string initialStatus  = PropertyHelper.InitialStatus;
            int    cvc2           = GenerationHelper.GenerateCvc();

            if (!_cardRepository.ValidateIdentifier(cardIdentifier))
            {
                await GenerateCard(account, type);
            }

            string bankIdentifier     = _accountPropertyRepository.GetPropertyModel().BankIdentificationNumber;
            string industryIdentifier = _accountPropertyRepository.GetPropertyModel().MajorIndustryIdentifier;
            string partialCardNumber  = industryIdentifier + bankIdentifier + account.Number + cardIdentifier;

            string checksum = GenerationHelper.GenerateChecksum(partialCardNumber);

            string cardNumber = partialCardNumber + checksum;

            Card card = new Card()
            {
                Name = type, AccountId = account.Id, IsDefault = true, UserId = account.UserId, Number = cardNumber, RegDate = DateTime.Now, ExpDate = DateTime.Now.AddYears(timeSpan), Status = initialStatus, Cvc2 = cvc2
            };

            await _cardRepository.InsertAsync(card);

            await _cardRepository.SaveAsync();
        }
コード例 #5
0
        public string CreateWebSessionFromDiscordId(string discordUserId)
        {
            ReportUser reportUser = _wrapper.ReportUserRepository.GetOne <ReportUser>(f => f.DiscordId == discordUserId);

            if (reportUser != null)
            {
                WebSession webSession = this.CreateWebSession(reportUser.Username);
                return(webSession.SessionCookie);
            }
            else
            {
                if (SystemShouldAutoCreateAccounts())
                {
                    ReportUser newUser = new ReportUser();
                    newUser.PasswordHash        = HashPassword(GenerationHelper.CreateRandomString(true, true, false, 20));
                    newUser.Username            = discordUserId;
                    newUser.IsOrganizationAdmin = false;
                    newUser.OrganizationRoles   = new List <string>();
                    _wrapper.ReportUserRepository.AddOne <ReportUser>(newUser);
                    WebSession webSession = this.CreateWebSession(newUser.Username);
                    return(webSession.SessionCookie);
                }
                else
                {
                    return("");
                }
            }
        }
コード例 #6
0
        public void Execute(int index)
        {
            ArrayHelper.To3DMap(index, out int x, out int y, out int z);

            int index2d = x * GeometryConsts.CHUNK_SIZE + z;

            Map[index] = GenerationHelper.GenerateVoxel(x + ChunkX * GeometryConsts.CHUNK_SIZE, y, z + ChunkY * GeometryConsts.CHUNK_SIZE, Heights[index2d], BiomeDefs[Biomes[index2d]], Lodes, LodeTresholds);
        }
コード例 #7
0
 protected override void Given()
 {
     firstInput           = "Vitaliy";
     secondInput          = "Gigexs";
     firstExpectedOutput  = "Vitaliy's";
     secondExpectedOutput = "Gigexs'";
     isValid = GenerationHelper.GetAccountName(firstInput) == firstExpectedOutput && GenerationHelper.GetAccountName(secondInput) == secondExpectedOutput;
 }
コード例 #8
0
        public override ExpressionCode GenerateCode()
        {
            var helper        = new GenerationHelper();
            var namespaceName = helper.GetFullNameFromIdNode(IdNode);

            return(new ExpressionCode {
                Code = Code.GenerateCode().Code
            });
        }
コード例 #9
0
        public ExpressionCode GenerateCode()
        {
            var helper = new GenerationHelper();
            var idName = helper.GetFullNameFromIdNode(IdNode);

            return(new ExpressionCode {
                Code = idName
            });
        }
コード例 #10
0
 private void GenerateContent()
 {
     GenerationHelper.AppendFileGeneatedMessageInCode(sb);
     this.AppendUsingStatements();
     sb.AppendLine("namespace " + this.GetLocalNamespace() + ".Entity");
     sb.AppendLine("{");
     this.AppendEntityClass();
     sb.AppendLine("}");
     sb.AppendLine();
 }
コード例 #11
0
        public void Execute(int index)
        {
            //ArrayHelper.To3D(index, out int x, out int y, out int z);

            //int index2d = x * GeometryLookups.CHUNK_SIZE + z;
            int x = Mathf.FloorToInt(index / (float)GeometryConsts.CHUNK_SIZE);
            int z = index % GeometryConsts.CHUNK_SIZE;

            Biomes[index]  = GenerationHelper.GetBiomeForColumn(x + ChunkX * GeometryConsts.CHUNK_SIZE, z + ChunkY * GeometryConsts.CHUNK_SIZE, BiomeDefs, Offsets, TerrainCurves, out int terrainHeight);
            Heights[index] = terrainHeight;
        }
コード例 #12
0
        /// <summary>
        /// Creates a new web session and return it for a given user.
        /// </summary>
        /// <param name="username">The username for which the session is for.</param>
        /// <returns>A WebSession</returns>
        public WebSession CreateWebSession(string username)
        {
            Player     player     = _wrapper.PlayerRepository.GetOne <Player>(f => f.Username == username);
            WebSession webSession = new WebSession();

            webSession.Expiry        = DateTime.UtcNow.AddDays(14);
            webSession.UserId        = player.Id;
            webSession.ForUsername   = username;
            webSession.SessionCookie = GenerationHelper.CreateRandomString(true, true, false, 32);
            _wrapper.WebSessionRepository.AddOne <WebSession>(webSession);
            return(webSession);
        }
コード例 #13
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var stringCode = "";

            stringCode += PrimitiveType.GenerateCode().Code + ".";
            stringCode += IdToken.Lexeme;
            stringCode += Accessor.GenerateCode().Code;
            stringCode += PostId;


            return(new ExpressionCode {
                Code = stringCode, Type = PrimitiveType.GenerateCode().Type
            });
        }
コード例 #14
0
        /// <summary>
        /// Adds a new access token for a given user with a default lifetime.
        /// </summary>
        /// <param name="username">The user in question.</param>
        /// <returns>Resulting AccessToken</returns>
        public AccessToken CreateGameplayToken(string username)
        {
            AccessToken accessToken = new AccessToken();

            accessToken.Content              = GenerationHelper.CreateRandomString(true, true, false, 20);
            accessToken.Expiry               = DateTime.UtcNow.AddMinutes(5);
            accessToken.RefreshToken         = new RefreshToken();
            accessToken.RefreshToken.Content = GenerationHelper.CreateRandomString(true, true, false, 20);
            accessToken.RefreshToken.Expiry  = DateTime.UtcNow.AddMinutes(10);
            Player player = _wrapper.PlayerRepository.GetOne <Player>(f => f.Username == username);

            accessToken.PlayerId = player.Id;
            _wrapper.AccessTokenRepository.AddOne <AccessToken>(accessToken);
            return(accessToken);
        }
コード例 #15
0
        /// <summary>
        /// Creates a new web session and return it for a given user.
        /// </summary>
        /// <param name="username">The username for which the session is for.</param>
        /// <returns>A WebSession</returns>
        public WebSession CreateWebSession(string username)
        {
            WebSession webSession = new WebSession();
            ReportUser reportUser = _wrapper.ReportUserRepository.GetOne <ReportUser>(f => f.Username == username);

            if (reportUser != null)
            {
                webSession.Expiry            = DateTime.UtcNow.AddDays(14);
                webSession.ReportUserId      = reportUser.Id;
                webSession.ForReportUsername = username;
                webSession.SessionCookie     = GenerationHelper.CreateRandomString(true, true, false, 32);
                _wrapper.WebSessionRepository.AddOne <WebSession>(webSession);
            }
            return(webSession);
        }
コード例 #16
0
        public void TestGenerateAllFiles_No_Files()
        {
            using (mocks.Record())
            {
                SetupFolder(folder, new IFolder[0], new IScript[0], new IFile[0], "");
                SetupProject();
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, new FileController());
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("fasdkj", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes, Is.Empty);
        }
コード例 #17
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var stringCode = "";

            stringCode += Type.GenerateCode().Code + ".";
            stringCode += Name.Lexeme;
            stringCode += Accesor.GenerateCode().Code;
            stringCode += PostId;


            return(new ExpressionCode {
                Code = stringCode
            });
        }
コード例 #18
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var stringCode = "";

            stringCode += IdNode.GenerateCode().Code;
            if (AssignmentNode != null)
            {
                stringCode += AssignmentNode.GenerateCode().Code;
            }
            stringCode += PostId;

            return(new ExpressionCode {
                Code = stringCode, Type = IdNode.GenerateCode().Type
            });
        }
コード例 #19
0
 private void GenerateContent()
 {
     try
     {
         GenerationHelper.AppendFileGeneatedMessageInCode(sb);
         this.AppendUsingStatements();
         sb.AppendLine($"namespace {this.GetLocalNamespace()}");
         sb.AppendLine("{");
         this.AppendExtensions();
         sb.AppendLine("}");
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #20
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var stringCode = "";

            stringCode += helper.GetFullNameFromIdNode(IdType);
            if (RankSpecifiers != null)
            {
                foreach (var rank in RankSpecifiers)
                {
                    stringCode += rank.GenerateCode().Code;
                }
            }
            return(new ExpressionCode {
                Code = "", Type = helper.GetFullNameFromIdNode(IdType)
            });
        }
コード例 #21
0
ファイル: GameService.cs プロジェクト: fossabot/Spaceplanets
        public void GenerateGalaxy(string galaxyName)
        {
            Galaxy galaxy = new Galaxy();

            galaxy.SizeX = _random.Next(50, 200);
            galaxy.SizeY = galaxy.SizeX; //_random.Next(200, 350);
            galaxy.SizeZ = _random.Next(1, 25);
            if (!string.IsNullOrEmpty(galaxyName))
            {
                galaxy.Name = galaxyName;
            }
            else
            {
                galaxy.Name = "Galaxy " + GenerationHelper.CreateRandomString(true, true, false, 5);
            }
            int volume      = galaxy.SizeX * galaxy.SizeY * galaxy.SizeZ;
            int lowerBoundX = (galaxy.SizeX / 2) * -1;
            int lowerBoundY = (galaxy.SizeY / 2) * -1;
            int lowerBoundZ = (galaxy.SizeZ / 2) * -1;
            int upperBoundX = lowerBoundX * -1;
            int upperBoundY = lowerBoundY * -1;
            int upperBoundZ = lowerBoundZ * -1;

            for (int Xctr = lowerBoundX; Xctr <= upperBoundX; Xctr++)
            {
                for (int Yctr = lowerBoundY; Yctr <= upperBoundY; Yctr++)
                {
                    for (int Zctr = lowerBoundZ; Zctr <= upperBoundZ; Zctr++)
                    {
                        // make random number to decide if this is a place a star should go.
                        int starChance = _random.Next(1, 1000);
                        if (starChance <= 2)
                        {
                            // create star
                            StarSystem starSystem = new StarSystem();
                            starSystem.Name = "System " + GenerationHelper.CreateRandomString(true, false, false, 6) + " " + GenerationHelper.CreateRandomString(false, true, false, 2);
                            starSystem.CreateRandomizedSpaceObjects(_random);
                            galaxy.StarSystems.Add(starSystem);
                        }
                    }
                }
            }
            _wrapper.GalaxyRepository.AddOne <Galaxy>(galaxy);
        }
コード例 #22
0
ファイル: MainForm.cs プロジェクト: peterchen/CodeBuilder
        public bool CheckParameters()
        {
            if (!GenerationHelper.IsValidPackageName(this.packageTxtBox.Text))
            {
                MessageBoxHelper.DisplayInfo("Package name is invalid,please input the english letters.");
                this.packageTxtBox.Focus();
                return(false);
            }

            if (this.templateListBox.SelectedItems == null ||
                this.templateListBox.SelectedItems.Count == 0)
            {
                MessageBoxHelper.DisplayInfo("You should select one template at least.");
                this.templateListBox.Focus();
                return(false);
            }

            return(true);
        }
コード例 #23
0
        public bool CheckParameters()
        {
            if (!GenerationHelper.IsValidPackageName(this.packageTxtBox.Text))
            {
                MessageBoxHelper.DisplayInfo(Resources.PackageNameInvalid);
                this.packageTxtBox.Focus();
                return(false);
            }

            if (this.templateListBox.SelectedItems == null ||
                this.templateListBox.SelectedItems.Count == 0)
            {
                MessageBoxHelper.DisplayInfo(Resources.ShouldSelectOneTemplate);
                this.templateListBox.Focus();
                return(false);
            }

            return(true);
        }
コード例 #24
0
        public DataConverter()
        {
            mapperConfiguration = new MapperConfiguration(c =>
            {
                c.CreateMap <Department, DepartmentModel>();
                c.CreateMap <Position, PositionModel>();

                c.CreateMap <Employee, EmployeeModel>()
                .ForMember(d => d.DayOfBirth, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.DayOfBirth, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.JoinedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.JoinedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.LeftDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.LeftDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.CreatedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.CreatedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.UpdatedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.UpdatedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.Department, o => o.MapFrom(s => s.Department))
                .ForMember(d => d.Position, o => o.MapFrom(s => s.Position));
            });

            mapper = new Mapper(mapperConfiguration);
        }
コード例 #25
0
ファイル: GenerationHelperTests.cs プロジェクト: tgspn/Zilon
        public void GetFreeCellTest()
        {
            // ARRANGE
            var rooms = new RoomMatrix(10);

            rooms.SetRoom(3, 3, new Room());
            var testedCoords = new OffsetCoords(3, 3);



            // ACT
            var factCoords = GenerationHelper.GetFreeCell(rooms, testedCoords);


            // ASSERT
            factCoords.Should().NotBeNull();
            var isEquals = factCoords.X == testedCoords.X && factCoords.Y == testedCoords.Y;

            isEquals.Should().BeFalse();
        }
コード例 #26
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var idName     = helper.GetFullNameFromIdNode(Id);
            var stringCode = "";

            stringCode += PreId;
            stringCode += idName;
            if (Accessor != null)
            {
                stringCode += Accessor.GenerateCode().Code;
            }

            var type = "string";

            if (SymbolTable.vars.ContainsKey(idName))
            {
                type = SymbolTable.vars[idName];
            }
            return(new ExpressionCode {
                Code = stringCode, Type = type
            });
        }
コード例 #27
0
        private void generateBtn_Click(object sender, EventArgs e)
        {
            if (!this.CheckParameters())
            {
                return;
            }
            var generationObjects = GenerationHelper.GetGenerationObjects(this.treeView);
            int genObjectCount    = generationObjects.Sum(x => x.Value.Count);

            if (genObjectCount == 0)
            {
                MessageBoxHelper.DisplayInfo(Resources.ShouldCheckedTreeNode);
                return;
            }

            int fileCount = genObjectCount * this.templateListBox.SelectedItems.Count;

            this.generateBtn.Enabled    = false;
            this.completedLbl.Visible   = false;
            this.totalFileCountLbl.Text = fileCount.ToString();
            this.genProgressBar.Maximum = fileCount;

            GenerationParameter parameter = new GenerationParameter(
                ModelManager.Clone(),
                GenerationHelper.GetGenerationObjects(this.treeView),
                this.GetGenerationSettings());

            try
            {
                this.codeGeneration.GenerateAsync(parameter, Guid.NewGuid().ToString());
            }
            catch (Exception ex)
            {
                logger.Error(Resources.GenerateFailure, ex);
            }
        }
コード例 #28
0
 protected override void Given()
 {
     actualResult = GenerationHelper.GenerateCvc().ToString();
     isValid      = actualResult.Length == 3;
 }
コード例 #29
0
 protected override void Given()
 {
     actualResult = GenerationHelper.GenerateIdentifier();
     isValid      = actualResult.Length == 4;
 }
コード例 #30
0
 public ErrorFromServer(string message)
 {
     this.ErrorId = GenerationHelper.CreateRandomString(true, true, false, 6);
     this.Message = message;
 }