Пример #1
0
        static void Main(string[] args)
        {
            var nullLog = new NullLog();
            var account = new Account(nullLog);

            account.SomeOperation();
        }
        public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true, string targetBranch = null)
        {
            if (configuration == null)
            {
                configuration = new Config();
                configuration.Reset();
            }

            var log = new NullLog();
            var metaDataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new TestBaseVersionStrategiesCalculator(log);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metaDataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metaDataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var variableProvider          = new VariableProvider(nextVersionCalculator, new TestEnvironment());
            var gitVersionContext         = new GitVersionContext(repository ?? fixture.Repository, log, targetBranch, configuration, isForTrackedBranchOnly, commitId);
            var executeGitVersion         = ExecuteGitVersion(gitVersionContext);
            var variables = variableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);

            try
            {
                return(variables);
            }
            catch (Exception)
            {
                Console.WriteLine("Test failing, dumping repository graph");
                gitVersionContext.Repository.DumpGraph();
                throw;
            }
        }
Пример #3
0
        public static void ChangeEmbeddedAttachmentLinks(this MailDraftData draft, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            var baseAttachmentFolder = MailStoragePathCombiner.GetMessageDirectory(draft.Mailbox.UserId, draft.StreamId);

            var doc = new HtmlDocument();

            doc.LoadHtml(draft.HtmlBody);
            var linkNodes = doc.DocumentNode.SelectNodes("//img[@src and (contains(@src,'" + baseAttachmentFolder + "'))]");

            if (linkNodes == null)
            {
                return;
            }

            foreach (var linkNode in linkNodes)
            {
                var link = linkNode.Attributes["src"].Value;
                log.InfoFormat("ChangeEmbededAttachmentLinks() Embeded attachment link for changing to cid: {0}", link);
                var fileLink = HttpUtility.UrlDecode(link.Substring(baseAttachmentFolder.Length));
                var fileName = Path.GetFileName(fileLink);

                var attach = CreateEmbbededAttachment(fileName, link, fileLink, draft.Mailbox.UserId, draft.Mailbox.TenantId, draft.Mailbox.MailBoxId, draft.StreamId);
                draft.AttachmentsEmbedded.Add(attach);
                linkNode.SetAttributeValue("src", "cid:" + attach.contentId);
                log.InfoFormat("ChangeEmbededAttachmentLinks() Attachment cid: {0}", attach.contentId);
            }
            draft.HtmlBody = doc.DocumentNode.OuterHtml;
        }
Пример #4
0
        public void CanSetNextVersion()
        {
            ILog        log         = new NullLog();
            IFileSystem fileSystem  = new TestFileSystem();
            IConsole    testConsole = new TestConsole("3", "2.0.0", "0");

            var serviceCollections = new ServiceCollection();

            serviceCollections.AddModule(new GitVersionInitModule());

            serviceCollections.AddSingleton(log);
            serviceCollections.AddSingleton(fileSystem);
            serviceCollections.AddSingleton(testConsole);

            var serviceProvider = serviceCollections.BuildServiceProvider();

            var stepFactory       = new ConfigInitStepFactory(serviceProvider);
            var configInitWizard  = new ConfigInitWizard(testConsole, stepFactory);
            var configFileLocator = new DefaultConfigFileLocator(fileSystem, log);
            var workingDirectory  = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj";

            var gitPreparer = new GitPreparer(log, new TestEnvironment(), Options.Create(new Arguments {
                TargetPath = workingDirectory
            }));
            var configurationProvider = new ConfigProvider(fileSystem, log, configFileLocator, gitPreparer, configInitWizard);

            configurationProvider.Init(workingDirectory);

            fileSystem.ReadAllText(Path.Combine(workingDirectory, "GitVersion.yml")).ShouldMatchApproved();
        }
        public void ShouldCreateFile(string fileExtension)
        {
            var fileSystem = new TestFileSystem();
            var directory  = Path.GetTempPath();
            var fileName   = "GitVersionInformation.g." + fileExtension;
            var fullPath   = Path.Combine(directory, fileName);

            var semanticVersion = new SemanticVersion
            {
                Major         = 1,
                Minor         = 2,
                Patch         = 3,
                PreReleaseTag = "unstable4",
                BuildMetaData = new SemanticVersionBuildMetaData("versionSourceSha", 5,
                                                                 "feature1", "commitSha", "commitShortSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
            };

            var log = new NullLog();
            var metaDataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new BaseVersionCalculator(log, null);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metaDataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metaDataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var variableProvider          = new VariableProvider(nextVersionCalculator, new TestEnvironment());
            var variables = variableProvider.GetVariablesFor(semanticVersion, new TestEffectiveConfiguration(), false);
            var generator = new GitVersionInformationGenerator(fileName, directory, variables, fileSystem);

            generator.Generate();

            fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension)));
        }
Пример #6
0
        public void Setup()
        {
            ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute <TestAttribute>();
            var log = new NullLog();

            variableProvider = new VariableProvider(log);
        }
Пример #7
0
 public IheTransactionTests()
 {
     _server = new MllpServer(
         new IPEndPoint(IPAddress.Loopback, Port),
         NullLog.Get(),
         new TestMiddleware());
     _server.Start();
 }
Пример #8
0
        public Session(
            IApplication app, IMessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, ILogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SenderDefaultApplVerID = senderDefaultApplVerID;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            ILog log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt)
            {
                MessageStore = storeFactory.Create(sessID)
            };

            // Configuration defaults.
            // Will be overridden by the SessionFactory with values in the user's configuration.
            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;
            this.MillisecondsInTimeStamp = true;
            this.EnableLastMsgSeqNumProcessed = false;
            this.MaxMessagesInResendRequest = 0;
            this.SendLogoutBeforeTimeoutDisconnect = false;
            this.IgnorePossDupResendRequests = false;
            this.RequiresOrigSendingTime = true;
            this.CheckLatency = true;
            this.MaxLatency = 120;

            if (!IsSessionTime)
                Reset("Out of SessionTime (Session construction)");
            else if (IsNewSession)
                Reset("New session");

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
        private FilesEventPersistence CreatePersistence(string storePath = "")
        {
            var log        = new NullLog();
            var serializer = new JsonSerializer();
            var config     = ConfigurePath(storePath);
            var locator    = new FilesEventLocator(config);

            return(new FilesEventPersistence(log, serializer, config, locator));
        }
Пример #10
0
        public void Setup()
        {
            fileSystem = new TestFileSystem();
            var log = new NullLog();

            configFileLocator = new DefaultConfigFileLocator(fileSystem, log);
            repoPath          = DefaultRepoPath;

            ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute <TestAttribute>();
        }
Пример #11
0
 public MllpServerTests()
 {
     _server = new MllpServer(
         new IPEndPoint(IPAddress.IPv6Loopback, 2575),
         NullLog.Get(),
         new DefaultHl7MessageMiddleware(
             handlers: new TestTransactionHandler()),
         TimeSpan.FromMilliseconds(100));
     _server.Start();
 }
Пример #12
0
        public void Start(int port, [CanBeNull] string filename)
        {
#if DEBUG
            var log = this;
#else
            var log = new NullLog();
#endif
            _server = new WebServer($"http://+:{port}/", log, RoutingStrategy.Wildcard);

            // HTTP part: index webpage, static files nearby (if any)
            var pages = new PagesProvider(filename);

            _server.RegisterModule(new WebApiModule());
            _server.Module <WebApiModule>().RegisterController(() => new IndexPageController(pages));

            if (Directory.Exists(pages.StaticDirectory))
            {
                _server.RegisterModule(new StaticFilesModule(new Dictionary <string, string> {
                    [@"/"] = pages.StaticDirectory
                })
                {
                    UseRamCache = false,
                    UseGzip     = false
                });
            }

            // Websockets part
            var module = new WebSocketsModule();
            _server.RegisterModule(module);

            _sharedServer = new PublishDataSocketsServer(@"Current Race Shared Memory Server");
            module.RegisterWebSocketsServer(@"/api/ws/shared", _sharedServer);

            _statsServer = new PublishDataSocketsServer(@"Current Race Stats Server");
            module.RegisterWebSocketsServer(@"/api/ws/stats", _statsServer);

            // Starting
            try {
                _server.RunAsync();
            } catch (HttpListenerException e) {
                NonfatalError.NotifyBackground("Can’t start web server",
                                               $"Don’t forget to allow port’s usage with something like “netsh http add urlacl url=\"http://+:{port}/\" user=everyone”.", e, new[] {
                    new NonfatalErrorSolution($"Use “netsh” to allow usage of port {port}", null, token => {
                        Process.Start(new ProcessStartInfo {
                            FileName  = "cmd",
                            Arguments = $"/C netsh http add urlacl url=\"http://+:{port}/\" user=everyone & pause",
                            Verb      = "runas"
                        });
                        return(Task.Delay(1000, token));
                    })
                });
            } catch (Exception e) {
                Logging.Error(e);
            }
        }
Пример #13
0
        public static void ChangeAllImagesLinksToEmbedded(this MailDraftData draft, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            try
            {
                var doc = new HtmlDocument();
                doc.LoadHtml(draft.HtmlBody);
                var linkNodes = doc.DocumentNode.SelectNodes("//img[@src]");
                if (linkNodes == null)
                {
                    return;
                }

                foreach (var linkNode in linkNodes)
                {
                    var link = linkNode.Attributes["src"].Value;
                    log.InfoFormat("ChangeAllImagesLinksToEmbedded() Link to img link: {0}", link);

                    var fileName = Path.GetFileName(link);

                    var data = StorageManager.LoadLinkData(link, log);

                    if (!data.Any())
                    {
                        continue;
                    }

                    var attach = new MailAttachmentData
                    {
                        fileName   = fileName,
                        storedName = fileName,
                        contentId  = link.GetMd5(),
                        data       = data
                    };

                    log.InfoFormat("ChangeAllImagesLinksToEmbedded() Embedded img link contentId: {0}", attach.contentId);
                    linkNode.SetAttributeValue("src", "cid:" + attach.contentId);

                    if (draft.AttachmentsEmbedded.All(x => x.contentId != attach.contentId))
                    {
                        draft.AttachmentsEmbedded.Add(attach);
                    }
                }

                draft.HtmlBody = doc.DocumentNode.OuterHtml;
            }
            catch (Exception ex)
            {
                log.ErrorFormat("ChangeAllImagesLinksToEmbedded(): Exception: {0}", ex.ToString());
            }
        }
Пример #14
0
        public static void ChangeEmbeddedAttachmentLinks(this MailDraftData draft, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            var baseAttachmentFolder = MailStoragePathCombiner.GetMessageDirectory(draft.Mailbox.UserId, draft.StreamId);

            var doc = new HtmlDocument();

            doc.LoadHtml(draft.HtmlBody);
            var linkNodes = doc.DocumentNode.SelectNodes("//img[@src and (contains(@src,'" + baseAttachmentFolder + "') or @x-mail-embedded)]");

            if (linkNodes == null)
            {
                return;
            }

            foreach (var linkNode in linkNodes)
            {
                var link = linkNode.Attributes["src"].Value;
                log.InfoFormat("ChangeEmbededAttachmentLinks() Embeded attachment link for changing to cid: {0}", link);

                var isExternal = link.IndexOf(baseAttachmentFolder) == -1;

                var fileLink = isExternal
                    ? link
                    : HttpUtility.UrlDecode(link.Substring(baseAttachmentFolder.Length));
                var fileName = Path.GetFileName(fileLink);

                var attach = CreateEmbbededAttachment(fileName, link, fileLink, draft.Mailbox.UserId, draft.Mailbox.TenantId, draft.Mailbox.MailBoxId, draft.StreamId);

                if (isExternal)
                {
                    using (var webClient = new WebClient())
                    {
                        //webClient.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
                        try
                        {
                            attach.data = webClient.DownloadData(fileLink);
                        }
                        catch (WebException we)
                        {
                            log.Error(we);
                            continue;
                        }
                    }
                }
                draft.AttachmentsEmbedded.Add(attach);
                linkNode.SetAttributeValue("src", "cid:" + attach.contentId);
                log.InfoFormat("ChangeEmbededAttachmentLinks() Attachment cid: {0}", attach.contentId);
            }
            draft.HtmlBody = doc.DocumentNode.OuterHtml;
        }
Пример #15
0
        public void Logging_NullLogTest()
        {
            IActionLinesLog log = new NullLog();

            log.WriteAsync(MessageCategory.Error, "message").Wait();
            log.WriteFormatAsync(MessageCategory.Error, "message").Wait();
            log.WriteLineAsync(MessageCategory.Error, "message").Wait();

            log.Content.Should().BeEmpty();
            log.Lines.Should().BeEmpty();
        }
Пример #16
0
        public void Setup()
        {
            ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute <TestAttribute>();
            var log = new NullLog();
            var metaDataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new BaseVersionCalculator(log, null);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metaDataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metaDataCalculator, baseVersionCalculator, mainlineVersionCalculator);

            variableProvider = new VariableProvider(nextVersionCalculator, new TestEnvironment());
        }
        private static SemanticVersion ExecuteGitVersion(GitVersionContext context)
        {
            var log = new NullLog();
            var metadataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new TestBaseVersionStrategiesCalculator(log);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metadataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metadataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var vf = new GitVersionFinder(log, nextVersionCalculator);

            return(vf.FindVersion(context));
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebdavConfig"/> class.
        /// </summary>
        /// <param name="dataStore">The data store.</param>
        /// <exception cref="System.ArgumentNullException">dataStore</exception>
        public WebdavConfig(IDataStore dataStore)
        {
            if (dataStore == null)
            {
                throw new ArgumentNullException("dataStore");
            }

            DataStore      = dataStore;
            _defaultLog    = new NullLog();
            _defaultDirGen = new BootstrapDirGenerator();
        }
Пример #19
0
    public void DepositUnitTestWithFake()
    {
        var log = new NullLog();

        ba = new BankAccountNew(log)
        {
            Balance = 100
        };
        ba.Deposit(100);

        Assert.That(ba.Balance, Is.EqualTo(200));
    }
        public void DepositIntegrationTestWithFake()
        {
            var log = new NullLog();

            _bankAccount = new BankAccount(log)
            {
                Balance = 100
            };

            _bankAccount.Deposit(100);
            Assert.That(_bankAccount.Balance, Is.EqualTo(200));
        }
        /// <summary>
        /// Simulates running on build server
        /// </summary>
        public static void InitializeRepo(this RemoteRepositoryFixture fixture)
        {
            var log = new NullLog();

            var arguments = new Arguments
            {
                Authentication = new Authentication(),
                TargetPath     = fixture.LocalRepositoryFixture.RepositoryPath
            };

            new GitPreparer(log, new TestEnvironment(), Options.Create(arguments)).Prepare(true, null);
        }
 public SecureIheTransactionTests()
 {
     _cert = new X509Certificate2Collection(
         new X509Certificate2("cert.pfx", "password"));
     _server = new MllpServer(
         new IPEndPoint(IPAddress.Loopback, _port),
         NullLog.Get(),
         new TestMiddleware(),
         serverCertificate: _cert[0],
         userCertificateValidationCallback: UserCertificateValidationCallback);
     _server.Start();
 }
Пример #23
0
        public static void ChangeSmileLinks(this MailDraftData draft, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            var baseSmileUrl = MailStoragePathCombiner.GetEditorSmileBaseUrl();

            var doc = new HtmlDocument();

            doc.LoadHtml(draft.HtmlBody);
            var linkNodes = doc.DocumentNode.SelectNodes("//img[@src and (contains(@src,'" + baseSmileUrl + "'))]");

            if (linkNodes == null)
            {
                return;
            }

            foreach (var linkNode in linkNodes)
            {
                var link = linkNode.Attributes["src"].Value;

                log.InfoFormat("ChangeSmileLinks() Link to smile: {0}", link);

                var fileName = Path.GetFileName(link);

                var data = StorageManager.LoadLinkData(link, log);

                if (!data.Any())
                {
                    continue;
                }

                var attach = new MailAttachmentData
                {
                    fileName   = fileName,
                    storedName = fileName,
                    contentId  = link.GetMd5(),
                    data       = data
                };

                log.InfoFormat("ChangeSmileLinks() Embedded smile contentId: {0}", attach.contentId);

                linkNode.SetAttributeValue("src", "cid:" + attach.contentId);

                if (draft.AttachmentsEmbedded.All(x => x.contentId != attach.contentId))
                {
                    draft.AttachmentsEmbedded.Add(attach);
                }
            }
            draft.HtmlBody = doc.DocumentNode.OuterHtml;
        }
Пример #24
0
        public void CanSetNextVersion()
        {
            var log               = new NullLog();
            var fileSystem        = new TestFileSystem();
            var testConsole       = new TestConsole("3", "2.0.0", "0");
            var configFileLocator = new DefaultConfigFileLocator(fileSystem, log);
            var workingDirectory  = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj";

            ConfigurationProvider.Init(workingDirectory, fileSystem, testConsole, log, configFileLocator);

            fileSystem.ReadAllText(Path.Combine(workingDirectory, "GitVersion.yml")).ShouldMatchApproved();
        }
Пример #25
0
        public MainForm()
        {
            InitializeComponent();

            // log
            foreach (string arg in Environment.GetCommandLineArgs())
            {
                if (arg == "--log")
                {
                    useLog = true;
                }
            }
            ILog log;

            miLog.Visible = useLog;
            if (useLog)
            {
                logForm = new LogForm();
                log     = new TextBoxLog(logForm.TextBox);
            }
            else
            {
                log = new NullLog();
            }

            // version string
            lbVersion.Text = GetVersion();

            // ip address
            try
            {
                lbIpAddr.Text = GetIpAddress();
            }
            catch
            {
                lbIpAddr.Text = "Unknown";
            }

            // input controller
            inputController = new WinInputController();

            // services
            dserver = new DiscoveryServer(log);
            iserver = new InputServer.InputServer(log, inputController);

            // hide window
            WindowState   = FormWindowState.Minimized;
            ShowInTaskbar = false;
        }
Пример #26
0
        public static void ChangeUrlProxyLinks(this MailDraftData draft, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            try
            {
                draft.HtmlBody = HtmlSanitizer.RemoveProxyHttpUrls(draft.HtmlBody);
            }
            catch (Exception ex)
            {
                log.ErrorFormat("ChangeUrlProxyLinks(): Exception: {0}", ex.ToString());
            }
        }
Пример #27
0
        public SecureIheTransactionWithSanTests()
        {
            var certificate = X509Certificate2.CreateFromPemFile("cert.pem", "san.pem");
            var buffer      = certificate.Export(X509ContentType.Pfx, (string)null);

            certificate = new X509Certificate2(buffer, (string)null);
            _cert       = new X509Certificate2Collection(
                certificate);
            _server = new MllpServer(
                new IPEndPoint(IPAddress.Loopback, _port),
                NullLog.Get(),
                new TestMiddleware(),
                serverCertificate: _cert[0],
                userCertificateValidationCallback: UserCertificateValidationCallback);
            _server.Start();
        }
Пример #28
0
        public CakeFixture()
        {
            var env = FakeEnvironment.CreateUnixEnvironment();

            FileSystem = new FakeFileSystem(env);
            var globber         = new Globber(FileSystem, env);
            var log             = new NullLog();
            var reg             = new WindowsRegistry();
            var config          = new CakeConfiguration(new Dictionary <string, string>());
            var strategy        = new ToolResolutionStrategy(FileSystem, env, globber, config, log);
            var toolLocator     = new ToolLocator(env, new ToolRepository(env), strategy);
            var cakeDataService = new FakeDataService();
            var runner          = new ProcessRunner(FileSystem, env, log, toolLocator, config);
            var args            = new FakeArguments();

            Context = new CakeContext(FileSystem, env, globber, log, args, runner, reg, toolLocator, cakeDataService, config);
        }
Пример #29
0
        private static void UploadToDocuments(Stream fileStream, string fileName, string contentType, MailBoxData mailbox, string httpContextScheme, ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            try
            {
                var apiHelper      = new ApiHelper(httpContextScheme);
                var uploadedFileId = apiHelper.UploadToDocuments(fileStream, fileName, contentType, mailbox.EMailInFolder, true);

                log.InfoFormat(
                    "EmailInEngine->UploadToDocuments(): file '{0}' has been uploaded to document folder '{1}' uploadedFileId = {2}",
                    fileName, mailbox.EMailInFolder, uploadedFileId);
            }
            catch (ApiHelperException ex)
            {
                if (ex.StatusCode == HttpStatusCode.NotFound || ex.StatusCode == HttpStatusCode.Forbidden)
                {
                    log.InfoFormat(
                        "EmailInEngine->UploadToDocuments() EMailIN folder '{0}' is unreachable. Try to unlink EMailIN...",
                        mailbox.EMailInFolder);

                    var engine = new EngineFactory(mailbox.TenantId, mailbox.UserId);

                    engine.AccountEngine.SetAccountEmailInFolder(mailbox.MailBoxId, null);

                    mailbox.EMailInFolder = null;

                    engine.AlertEngine.CreateUploadToDocumentsFailureAlert(mailbox.TenantId, mailbox.UserId,
                                                                           mailbox.MailBoxId,
                                                                           ex.StatusCode == HttpStatusCode.NotFound
                            ? UploadToDocumentsErrorType
                                                                           .FolderNotFound
                            : UploadToDocumentsErrorType
                                                                           .AccessDenied);

                    throw;
                }

                log.ErrorFormat("EmailInEngine->UploadToDocuments(fileName: '{0}', folderId: {1}) Exception:\r\n{2}\r\n",
                                fileName, mailbox.EMailInFolder, ex.ToString());
            }
        }
Пример #30
0
        /// <summary>
        /// Creates Rfc 2822 3.6.4 message-id. Syntax: id-left '@' id-right
        /// </summary>
        public static string CreateMessageId(ILog log = null)
        {
            if (log == null)
            {
                log = new NullLog();
            }

            var domain = "";

            try
            {
                var tenant = CoreContext.TenantManager.GetCurrentTenant();

                if (tenant != null)
                {
                    domain = tenant.GetTenantDomain();
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("CreateMessageId: GetTenantDomain failed: Exception\r\n{0}\r\n", ex.ToString());
            }

            if (string.IsNullOrEmpty(domain))
            {
                domain = System.Net.Dns.GetHostName();
            }

            try
            {
                var indexСolon = domain.IndexOf(":", StringComparison.Ordinal);

                if (indexСolon != -1)
                {
                    domain = domain.Remove(indexСolon, domain.Length - indexСolon);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("CreateMessageId: Remove colon failed: Exception\r\n{0}\r\n", ex.ToString());
            }

            return(string.Format("AU{0}@{1}", GetUniqueString(), domain));
        }
        public void FindsVersionInDynamicRepo(string name, string url, string targetBranch, string commitId, string expectedFullSemVer)
        {
            var root             = Path.Combine(workDirectory, name);
            var dynamicDirectory = Path.Combine(root, "D"); // dynamic, keeping directory as short as possible
            var workingDirectory = Path.Combine(root, "W"); // working, keeping directory as short as possible
            var arguments        = new Arguments
            {
                TargetUrl = url,
                DynamicRepositoryLocation = dynamicDirectory,
                TargetBranch = targetBranch,
                NoFetch      = false,
                TargetPath   = workingDirectory,
                CommitId     = commitId
            };
            var options = Options.Create(arguments);

            Directory.CreateDirectory(dynamicDirectory);
            Directory.CreateDirectory(workingDirectory);

            var testFileSystem      = new TestFileSystem();
            var log                 = new NullLog();
            var configFileLocator   = new DefaultConfigFileLocator(testFileSystem, log);
            var gitVersionCache     = new GitVersionCache(testFileSystem, log);
            var buildServerResolver = new BuildServerResolver(null, log);

            var metadataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new TestBaseVersionStrategiesCalculator(log);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metadataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metadataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var gitVersionFinder          = new GitVersionFinder(log, nextVersionCalculator);

            var gitPreparer      = new GitPreparer(log, new TestEnvironment(), options);
            var stepFactory      = new ConfigInitStepFactory();
            var configInitWizard = new ConfigInitWizard(new ConsoleAdapter(), stepFactory);

            var configurationProvider = new ConfigProvider(testFileSystem, log, configFileLocator, gitPreparer, configInitWizard);

            var variableProvider     = new VariableProvider(nextVersionCalculator, new TestEnvironment());
            var gitVersionCalculator = new GitVersionCalculator(testFileSystem, log, configFileLocator, configurationProvider, buildServerResolver, gitVersionCache, gitVersionFinder, gitPreparer, variableProvider, options);

            var versionVariables = gitVersionCalculator.CalculateVersionVariables();

            Assert.AreEqual(expectedFullSemVer, versionVariables.FullSemVer);
        }