Esempio n. 1
0
        public async Task ShouldNotWorkIfNotBuilt()
        {
            await using var testSolution = await CopyTestAssets("demowebsite");

            var projectPath = Path.Join(testSolution.Value, "demowebsite");

            await using var iisHost = new IISHost(new Dictionary <string, string>());
            using var cancel        = new CancellationTokenSource();

            var port = CreateRandomPort();
            var name = "demosolutionsitename";
            var run  = iisHost.Run(_console, new CommandArguments
            {
                Path    = new DirectoryInfo(projectPath),
                Port    = port,
                Name    = name,
                NoBuild = true
            }, cancel.Token);

            try
            {
                var httpClient = new HttpClient();
                var res        = await Retry.Get(() => httpClient.GetAsync($"http://localhost:{port}/DemoApi"), 20, Retry.ConstantTimeBackOff());

                Assert.False(res.IsSuccessStatusCode);
            }
            finally
            {
                cancel.Cancel();
                await run;
            }
        }
Esempio n. 2
0
        public async Task ShouldRunWebsite()
        {
            await using var testSolution = await CopyTestAssets("demowebsite");

            var projectPath = Path.Join(testSolution.Value, "demowebsite");

            await using var iisHost = new IISHost(new Dictionary <string, string>());
            using var cancel        = new CancellationTokenSource();

            var port = CreateRandomPort();
            var name = "demosolutionsitename";
            var run  = iisHost.Run(_console, new CommandArguments
            {
                Path = new DirectoryInfo(projectPath),
                Port = port,
                Name = name
            }, cancel.Token);

            try
            {
                var httpClient = new HttpClient();
                var res        = await Retry.Get(() => httpClient.GetAsync($"http://localhost:{port}/DemoApi"), 20, Retry.ConstantTimeBackOff());

                if (!res.IsSuccessStatusCode)
                {
                    _console.Out.WriteLine(await res.Content.ReadAsStringAsync());
                }

                Assert.True(res.IsSuccessStatusCode);

                var json = await JsonSerializer.DeserializeAsync <Dictionary <string, string> >(await res.Content.ReadAsStreamAsync());

                Assert.Equal(name, json["siteName"]);
            }
            finally
            {
                cancel.Cancel();
                await run;
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                string title             = Title.Get(context);
                int    matchingThreshold = MatchingThreshold.Get(context);
                int    matchingInterval  = MatchingInterval.Get(context);
                int    retry             = Retry.Get(context);

                var ret = ImageActionCommon.CVMouseAction(SourceImgPath, FlaxCV.CvActionType.DoubleClick, title, matchingThreshold, matchingInterval, retry);
                Result.Set(context, ret.IsMatched);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Error on Executing ImageDoubleClickActivity()", e.Message);
                if (ContinueOnError.Get(context))
                {
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 4
0
 public List <DomainObjects.News.News> ReadRssSource(string sourceUrl, int sourceId)
 {
     return(Retry.Get().Execute <List <DomainObjects.News.News> >((Func <string, int, List <DomainObjects.News.News> >)ReadRssSourceSync, sourceUrl, sourceId));
 }
Esempio n. 5
0
 protected string GetWithRetry(string route, params int[] consideredSuccessStatusCode)
 {
     return(Retry.Get().Execute <string>((Func <string, int[], string>)Get, route, consideredSuccessStatusCode));
 }
Esempio n. 6
0
 protected string PostWithRetry(string route, object contentObject, params int[] consideredSuccessStatusCode)
 {
     return(Retry.Get().Execute <string>((Func <string, object, int[], string>)Post, route, contentObject, consideredSuccessStatusCode));
 }
Esempio n. 7
0
 public static Dictionary <DateTime, double> GetCloseCryptoValue(string symbol)
 {
     return(Retry.Get().Execute <Dictionary <DateTime, double> >((Func <string, Dictionary <DateTime, double> >)InternalGetCloseCryptoValue, symbol));
 }
Esempio n. 8
0
 private double?CallApiWithRetry(string fromSymbol, string toSymbol, DateTime queryDate)
 {
     return(Retry.Get().Execute <double?>((Func <string, string, DateTime, double?>)CallApi, fromSymbol, toSymbol, queryDate));
 }