Exemplo n.º 1
0
        public void CreateFile_Success()
        {
            //Arrange
            Exception       exception        = null;
            string          expectedFilePath = Path.Combine(TestContext.DeploymentDirectory, "newlocker.bin");
            CreateArguments arguments        = new CreateArguments
            {
                LockerPath = expectedFilePath,
                Password   = "******"
            };

            //Act
            try
            {
                Program.CreateFile(arguments);
            }
            catch (Exception e)
            {
                exception = e;
            }

            //Assert
            Assert.IsNull(exception, $"Was not expecting an exception [{exception}]");

            bool fileExists = File.Exists(expectedFilePath);

            Assert.IsTrue(fileExists, "Was expecting a locker file to exist");
        }
Exemplo n.º 2
0
            public async Task Create(CreateArguments arguments)
            {
                var session = configuration.StartSession(arguments.App);

                var backupStarted = DateTime.UtcNow.AddMinutes(-5);

                await session.Backups.PostBackupAsync(session.App);

                log.WriteLine("Backup started, waiting for completion...");

                BackupJobDto?foundBackup = null;

                using (var tcs = new CancellationTokenSource(TimeSpan.FromMinutes(arguments.Timeout)))
                {
                    while (!tcs.Token.IsCancellationRequested)
                    {
                        var backups = await session.Backups.GetBackupsAsync(session.App, tcs.Token);

                        var backup = backups.Items.Find(x => x.Started >= backupStarted);

                        if (backup?.Stopped != null)
                        {
                            foundBackup = backup;
                            break;
                        }
                    }

                    await Task.Delay(5000, tcs.Token);
                }

                if (foundBackup == null)
                {
                    log.WriteLine("Failed to receive the backup in time.");
                }
                else if (foundBackup.Status == JobStatus.Completed)
                {
                    log.WriteLine("Backup completed. Downloading...");

                    await using (var fs = new FileStream(arguments.File, FileMode.CreateNew))
                    {
                        using (var download = await session.Backups.GetBackupContentAsync(session.App, foundBackup.Id))
                        {
                            await download.Stream.CopyToAsync(fs);
                        }
                    }

                    if (arguments.DeleteAfterDownload)
                    {
                        log.WriteLine("Removing backup from app...");

                        await session.Backups.DeleteBackupAsync(session.App, foundBackup.Id);
                    }

                    log.WriteLine("> Backup completed and downloaded");
                }
                else
                {
                    log.WriteLine("> Failed to make the backup, check the logs for details.");
                }
            }
Exemplo n.º 3
0
            public async Task Create(CreateArguments arguments)
            {
                var(app, service) = Configuration.Setup();

                var backupStarted = DateTime.UtcNow.AddMinutes(-5);
                var backupsClient = service.CreateBackupsClient();

                await backupsClient.PostBackupAsync(app);

                Console.WriteLine("Backup started, waiting for completion...");

                BackupJobDto foundBackup = null;

                using (var tcs = new CancellationTokenSource(TimeSpan.FromMinutes(arguments.Timeout)))
                {
                    while (!tcs.Token.IsCancellationRequested)
                    {
                        var backups = await backupsClient.GetBackupsAsync(app);

                        var backup = backups.Items.FirstOrDefault(x => x.Started >= backupStarted);

                        if (backup != null && backup.Stopped.HasValue)
                        {
                            foundBackup = backup;
                            break;
                        }
                    }

                    await Task.Delay(5000);
                }

                if (foundBackup == null)
                {
                    Console.WriteLine("Failed to receive the backup in time.");
                }
                else if (foundBackup.Status == JobStatus.Completed)
                {
                    Console.WriteLine("Backup completed. Downloading...");

                    using (var fs = new FileStream(arguments.File, FileMode.CreateNew))
                    {
                        using (var download = await backupsClient.GetBackupContentAsync(app, foundBackup.Id.ToString()))
                        {
                            await download.Stream.CopyToAsync(fs);
                        }
                    }

                    Console.WriteLine("Backup completed. Download completed");

                    if (arguments.DeleteAfterDownload)
                    {
                        Console.WriteLine("Removing backup from app...");
                        await backupsClient.DeleteBackupAsync(app, foundBackup.Id.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Failed to make the backup, check the logs for details.");
                }
            }
Exemplo n.º 4
0
 public Com.Daml.Ledger.Api.V1.CreateAndExerciseCommand ToProto()
 {
     return(new Com.Daml.Ledger.Api.V1.CreateAndExerciseCommand {
         TemplateId = TemplateId.ToProto(), CreateArguments = CreateArguments.ToProtoRecord(),
         Choice = Choice, ChoiceArgument = ChoiceArgument.ToProto()
     });
 }
        public GitHubIssueMock()
        {
            issues = new Mock <IIssuesClient>(MockBehavior.Strict);

            issues
            .Setup(issues => issues.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <NewIssue>()))
            .ReturnsAsync((Func <string, string, NewIssue, Issue>)CreateIssue)
            .Callback <string, string, NewIssue>(
                (owner, name, newIssue) =>
            {
                CreateIssueArgs = new CreateArguments(owner, name, newIssue);
            });

            issues
            .Setup(issues => issues.Update(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <IssueUpdate>()))
            .ReturnsAsync((Func <string, string, int, IssueUpdate, Issue>)UpdateIssue)
            .Callback <string, string, int, IssueUpdate>(
                (owner, name, number, issueUpdate) =>
            {
                UpdateIssueArgs = new UpdateArguments(owner, name, number, issueUpdate);
            });

            comment = new Mock <IIssueCommentsClient>(MockBehavior.Strict);

            comment
            .Setup(comment => comment.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>()))
            .ReturnsAsync((Func <string, string, int, string, IssueComment>)CreateComment)
            .Callback <string, string, int, string>(
                (owner, name, number, newComment) =>
            {
                createCommentArgs.Add(new CreateCommentArguments(owner, name, number, newComment));
            });

            comment
            .Setup(comment => comment.Delete(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns(CompletedTask)
            .Callback <string, string, int>(
                (owner, name, number) =>
            {
                deleteCommentArgs.Add(new DeleteCommentArguments(owner, name, number));
            });

            comment
            .Setup(comment => comment.GetAllForIssue(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()))
            .ReturnsAsync((Func <string, string, int, IReadOnlyList <IssueComment> >)GetAllCommentsForIssue)
            .Callback <string, string, int>(
                (owner, name, number) =>
            {
                GetAllCommentsForIssueArgs = new GetAllCommentsForIssueArguments(owner, name, number);
            });

            issues.Setup(issues => issues.Comment).Returns(Comment);

            createCommentArgs = new List <CreateCommentArguments>();
            deleteCommentArgs = new List <DeleteCommentArguments>();
            issueComments     = new Dictionary <int, IssueComment[]>();
        }
Exemplo n.º 6
0
        public void CreateFile(string FileFullName, NFSPermission Mode)
        {
            if (_ProtocolV2 == null)
            {
                throw new NFSConnectionException("NFS Client not connected!");
            }

            if (_MountProtocolV2 == null)
            {
                throw new NFSMountConnectionException("NFS Device not connected!");
            }

            if (Mode == null)
            {
                Mode = new NFSPermission(7, 7, 7);
            }

            string ParentDirectory = System.IO.Path.GetDirectoryName(FileFullName);
            string FileName        = System.IO.Path.GetFileName(FileFullName);

            NFSAttributes ParentItemAttributes = GetItemAttributes(ParentDirectory);

            CreateArguments dpArgCreate = new CreateArguments();

            dpArgCreate.Attributes = new CreateAttributes();
            dpArgCreate.Attributes.LastAccessedTime = new NFSTimeValue();
            dpArgCreate.Attributes.ModifiedTime     = new NFSTimeValue();
            dpArgCreate.Attributes.Mode             = Mode;
            dpArgCreate.Attributes.UserID           = this._UserID;
            dpArgCreate.Attributes.GroupID          = this._GroupID;
            dpArgCreate.Attributes.Size             = 0;
            dpArgCreate.Where           = new ItemOperationArguments();
            dpArgCreate.Where.Directory = new NFSHandle(ParentItemAttributes.Handle, V2.RPC.NFSv2Protocol.NFS_VERSION);
            dpArgCreate.Where.Name      = new Name(FileName);

            ItemOperationStatus pDirOpRes =
                _ProtocolV2.NFSPROC_CREATE(dpArgCreate);

            if (pDirOpRes == null ||
                pDirOpRes.Status != NFSStats.NFS_OK)
            {
                if (pDirOpRes == null)
                {
                    throw new NFSGeneralException("NFSPROC_CREATE: failure");
                }

                ExceptionHelpers.ThrowException(pDirOpRes.Status);
            }
        }
Exemplo n.º 7
0
            public async Task Create(CreateArguments arguments)
            {
                var session = configuration.StartSession();

                var name = arguments.Name;

                if (string.IsNullOrWhiteSpace(name))
                {
                    name = session.App;
                }

                var request = new CreateAppDto
                {
                    Name = name
                };

                await session.Apps.PostAppAsync(request);

                log.WriteLine("> App created.");
            }
 public void OnCreated(CreateArguments arguments)
 {
     this.eventBus = arguments.ComponentManager.CreateComponent <IEventBus>();
 }
        public void OnCreating(CreateArguments arguments)
        {
            var app = arguments.ComponentManager.CreateComponent <App>();

            app.Context["LastCreated"] = this.GetType();
        }