Example #1
0
 public void SelectOrderRefNumber()
 {
     orderReferenceNumber = ObjectRepository.Driver.FindElement(By.XPath("//a[@class='color-myaccount']"));
     MethodHelpers.WaitForElementToBeDisplayed(orderReferenceNumber);
     orderReferenceNumber.Click();
     Console.WriteLine("orderReferenceNumber dispplays as " + orderReferenceNumber.Text);
 }
Example #2
0
        public void TestFuncNameOutput()
        {
            var expectedOutput = new List <string>()
            {
                "test.unittest1+<>c.<testfuncnameoutput>b__9_0",
                "test.unittest1+<>c.<testfuncnameoutput>b__9_0",
                "test.unittest1+<>c.<testfuncnameoutput>b__9_0",
                "test.unittest1+<>c.<testfuncnameoutput>b__9_0",
                "benchmark_dotnet.testclass.testfuncnameoutput",
                "benchmark_dotnet.testclass.testfuncnameoutput"
            };

            var result = _sut.TestFuncNameOutput(() =>
                                                 new List <string>()
            {
                MethodHelpers.GetCurrentMethod(),
                MethodHelpers.GetCurrentMethod(false),
                MethodHelpers.StackFrame(true),
                MethodHelpers.StackFrame(false),
                MethodHelpers.CallerMemberName(nameof(benchmark_dotnet), nameof(TestClass)),
                MethodHelpers.CallerMemberName <TestClass>()
            }.ToArray());

            for (int i = 0; i < result.Length; i++)
            {
                Assert.Equal(expectedOutput[i], result[i]);
            }
        }
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp   = GetDateTimeOffset(tmp.Key);
            TextBox.Text = GetString(tmp.Value);
        }
Example #4
0
 protected virtual StatementSyntax GenerateRequestMessageVariable(
     ILocatedOpenApiElement <OpenApiOperation> operation) =>
 MethodHelpers.LocalVariableDeclarationWithInitializer(RequestMessageVariableName,
                                                       ObjectCreationExpression(WellKnownTypes.System.Net.Http.HttpRequestMessage.Name)
                                                       .AddArgumentListArguments(
                                                           Argument(GetRequestMethod(operation)),
                                                           Argument(BuildUriMethodGenerator.InvokeBuildUri(ThisExpression()))));
Example #5
0
        protected override BlockSyntax GenerateApplyAsyncBody() => Block(
            MethodHelpers.ThrowIfArgumentNull(MessageParameterName),

            MethodHelpers.IfNull(IdentifierName(CacheFieldName), Block(
                                     ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression,
                                                                              IdentifierName(CacheFieldName),
                                                                              WellKnownTypes.System.Convert.ToBase64String(WellKnownTypes.System.Text.Encoding.GetBytes(
                                                                                                                               WellKnownTypes.System.Text.Encoding.UTF8,
                                                                                                                               BinaryExpression(SyntaxKind.AddExpression,
                                                                                                                                                BinaryExpression(SyntaxKind.AddExpression,
                                                                                                                                                                 IdentifierName(UsernamePropertyName),
                                                                                                                                                                 SyntaxHelpers.StringLiteral(":")),
                                                                                                                                                IdentifierName(PasswordPropertyName))
                                                                                                                               ))))
                                     )),

            ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression,
                                                     MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                            MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                                                   IdentifierName(MessageParameterName),
                                                                                                   IdentifierName("Headers")),
                                                                            IdentifierName("Authorization")),
                                                     ObjectCreationExpression(WellKnownTypes.System.Net.Http.Headers.AuthenticationHeaderValue.Name)
                                                     .AddArgumentListArguments(
                                                         Argument(SyntaxHelpers.StringLiteral("Basic")),
                                                         Argument(IdentifierName(CacheFieldName))))),

            ReturnStatement(LiteralExpression(SyntaxKind.DefaultLiteralExpression)));
Example #6
0
 private static void RemoveIfNotNull(IMethodRemover methodRemover, MethodInfo mi)
 {
     if (mi is not null)
     {
         MethodHelpers.SafeRemoveMethod(methodRemover, mi);
     }
 }
 protected virtual StatementSyntax GenerateAuthenticatorVariable() =>
 MethodHelpers.LocalVariableDeclarationWithInitializer(AuthenticatorVariableName,
                                                       InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                                                   IdentifierName(TagTypeGenerator.AuthenticatorsFieldName),
                                                                                                   IdentifierName("SelectAuthenticator")))
                                                       .AddArgumentListArguments(
                                                           Argument(IdentifierName(RequestParameterName))));
Example #8
0
        private static IOrderedQueryable <T> DynamicOrderBy <T>(IQueryable <T> query, OrderByItem orderBy)
        {
            var func = MethodHelpers.GetMethodInfo(DynamicOrderBy <T, object>, query, orderBy)
                       .GetGenericMethodDefinition()
                       .MakeGenericMethod(typeof(T), orderBy.Expression.PropertyInfo().PropertyType);

            return((IOrderedQueryable <T>)func.Invoke(null, new object[] { query, orderBy }));
        }
        private IQueryable ApplyFilter(IQueryable query, QueryContext context)
        {
            var method = MethodHelpers.GetMethodInfo(ApplyFilter <object>, default(IQueryable <object>), context)
                         .GetGenericMethodDefinition()
                         .MakeGenericMethod(query.ElementType);

            return((IQueryable)method.Invoke(this, new object[] { query, context }));
        }
Example #10
0
        public void SelectMonth(string month)
        {
            monthOfBirth = ObjectRepository.Driver.FindElement(By.CssSelector("#months"));
            driver       = ObjectRepository.Driver;
            SelectElement selectElement = new SelectElement(driver.FindElement(By.CssSelector("#months")));

            MethodHelpers.WaitForPageToLoad(monthOfBirth);
            selectElement.SelectByValue(month);
        }
 protected virtual MethodDeclarationSyntax GenerateProcessResponseAsyncMethod() =>
 MethodDeclaration(WellKnownTypes.System.Threading.Tasks.ValueTask.Name, "ProcessResponseAsync")
 .WithModifiers(ProcessResponseUsesAsyncAwait ? _withAsyncModifiers : _withoutAsyncModifiers)
 .WithLeadingTrivia(DocumentationSyntaxHelpers.InheritDocTrivia)
 .AddParameterListParameters(
     Parameter(Identifier(MessageParameterName))
     .WithType(WellKnownTypes.System.Net.Http.HttpResponseMessage.Name),
     MethodHelpers.DefaultedCancellationTokenParameter())
 .WithBody(GenerateProcessResponseAsyncBody());
Example #12
0
        public void SelectYear(string year)
        {
            yearOfBirth = ObjectRepository.Driver.FindElement(By.CssSelector("#uniform-years"));
            driver      = ObjectRepository.Driver;
            SelectElement selectElement = new SelectElement(driver.FindElement(By.CssSelector("#uniform-years")));

            MethodHelpers.WaitForPageToLoad(yearOfBirth);
            selectElement.SelectByValue(year);
        }
Example #13
0
        public void SelectDay(string day)
        {
            days   = ObjectRepository.Driver.FindElement(By.CssSelector("#days"));
            driver = ObjectRepository.Driver;
            SelectElement selectElement = new SelectElement(driver.FindElement(By.CssSelector("#days")));

            MethodHelpers.WaitForPageToLoad(days);
            selectElement.SelectByText(day);
        }
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp = GetDateTimeOffset(tmp.Key);
            _guid      = GetGuid(tmp.Value);

            guidBox.Text = _guid.ToString();
        }
Example #15
0
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp      = GetDateTimeOffset(tmp.Key);
            _dateTimeOffset = GetDateTimeOffset(tmp.Value);

            dateBox.SelectedDate = _dateTimeOffset.DateTime;
        }
Example #16
0
        public void SelectState(string state)
        {
            state_ = ObjectRepository.Driver.FindElement(By.CssSelector("#uniform-id_state"));
            driver = ObjectRepository.Driver;
            SelectElement selectElement = new SelectElement(driver.FindElement(By.CssSelector("#uniform-id_state")));

            MethodHelpers.WaitForPageToLoad(state_);
            selectElement.SelectByValue(state);
        }
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp = GetDateTimeOffset(tmp.Key);
            _char      = GetChar(tmp.Value);

            charBox.Text   = _char.ToString();
            numberBox.Text = ((ushort)_char).ToString();
        }
Example #18
0
    public void TurnInGoalItems()
    {
        CollectionGoal collectionGoal = (CollectionGoal)goal;
        Item           goalItem       = ItemDatabase.instance.getItem(collectionGoal.itemSlug);

        MethodHelpers.RepeatAction(
            collectionGoal.requiredAmount,
            () => { InventoryController.instance.OfferItem(goalItem); }
            );
    }
Example #19
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var method = MethodHelpers.FindMethod(reflector, type, MethodType.Class, RecognisedMethodsAndPrefixes.MenuMethod, null, null);

            methodRemover.SafeRemoveMethod(method);
            var facet = method is not null ? (IFacet) new MenuFacetViaMethod(method, specification) : new MenuFacetDefault(specification);

            FacetUtils.AddFacet(facet);
            return(metamodel);
        }
Example #20
0
 protected virtual MethodDeclarationSyntax GenerateProcessResponseAsyncMethod() =>
 MethodDeclaration(WellKnownTypes.System.Threading.Tasks.ValueTask.Name, "ProcessResponseAsync")
 .AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.VirtualKeyword),
               Token(SyntaxKind.AsyncKeyword))
 .WithLeadingTrivia(
     DocumentationSyntaxHelpers.BuildXmlCommentTrivia(
         DocumentationSyntaxHelpers.BuildInheritDocElement()))
 .AddParameterListParameters(
     Parameter(Identifier(MessageParameterName))
     .WithType(WellKnownTypes.System.Net.Http.HttpResponseMessage.Name),
     MethodHelpers.DefaultedCancellationTokenParameter())
 .WithBody(GenerateProcessResponseAsyncBody());
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp = GetDateTimeOffset(tmp.Key);
            var rect = GetRect(tmp.Value);

            xBox.Text      = rect.X.ToString("G17");
            yBox.Text      = rect.Y.ToString("G17");
            widthBox.Text  = rect.Width.ToString("G17");
            heightBox.Text = rect.Height.ToString("G17");
        }
        protected virtual IEnumerable <StatementSyntax> GenerateStatements(
            ILocatedOpenApiElement <OpenApiOperation> operation)
        {
            ILocatedOpenApiElement <OpenApiResponses> responseSet     = operation.GetResponseSet();
            ILocatedOpenApiElement <OpenApiResponse>  primaryResponse = responseSet
                                                                        .GetResponses()
                                                                        .OrderBy(p => p.Key)
                                                                        .First();

            ILocatedOpenApiElement <OpenApiMediaType>?mediaType = MediaTypeSelector.Select(primaryResponse);

            if (mediaType != null)
            {
                yield return(ExpressionStatement(InvocationExpression(
                                                     SyntaxHelpers.MemberAccess(RequestMessageParameterName, "Headers", "Accept", "Add"))
                                                 .AddArgumentListArguments(
                                                     Argument(ObjectCreationExpression(WellKnownTypes.System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Name)
                                                              .AddArgumentListArguments(
                                                                  Argument(SyntaxHelpers.StringLiteral(mediaType.Key)))))));
            }

            var propertyNameFormatter = NameFormatterSelector.GetFormatter(NameKind.Property);

            foreach (var headerParameter in operation.Element.Parameters.Where(p => p.In == ParameterLocation.Header))
            {
                string propertyName = propertyNameFormatter.Format(headerParameter.Name);

                StatementSyntax statement = ExpressionStatement(InvocationExpression(
                                                                    SyntaxHelpers.MemberAccess(RequestMessageParameterName, "Headers", "Add"))
                                                                .AddArgumentListArguments(
                                                                    Argument(SyntaxHelpers.StringLiteral(headerParameter.Name)),
                                                                    Argument(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                                                                         SerializationNamespace.HeaderSerializerInstance,
                                                                                                                         IdentifierName("Serialize")))
                                                                             .AddArgumentListArguments(
                                                                                 Argument(IdentifierName(propertyName)),
                                                                                 Argument(headerParameter.Explode
                                    ? LiteralExpression(SyntaxKind.TrueLiteralExpression)
                                    : LiteralExpression(SyntaxKind.FalseLiteralExpression))))));

                if (!headerParameter.Required)
                {
                    statement = MethodHelpers.IfNotNull(
                        IdentifierName(propertyName),
                        Block(statement));
                }

                yield return(statement);
            }
        }
 protected override BlockSyntax GenerateApplyAsyncBody() =>
 Block(
     MethodHelpers.ThrowIfArgumentNull(MessageParameterName),
     MethodHelpers.IfNotNull(IdentifierName(BearerTokenPropertyName), Block(
                                 ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression,
                                                                          MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                                                 MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                                                                        IdentifierName(MessageParameterName),
                                                                                                                        IdentifierName("Headers")),
                                                                                                 IdentifierName("Authorization")),
                                                                          ObjectCreationExpression(WellKnownTypes.System.Net.Http.Headers.AuthenticationHeaderValue.Name)
                                                                          .AddArgumentListArguments(
                                                                              Argument(SyntaxHelpers.StringLiteral("Bearer")),
                                                                              Argument(IdentifierName(BearerTokenPropertyName))))))));
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var method = MethodHelpers.FindMethod(reflector, type, MethodType.Class, RecognisedMethodsAndPrefixes.MenuMethod, null, null);

            if (method is not null)
            {
                FacetUtils.AddFacet(new MenuFacetViaMethod(method, specification));
            }
            else
            {
                FacetUtils.AddFacet(new MenuFacetDefault(specification));
            }

            return(metamodel);
        }
Example #25
0
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp = GetDateTimeOffset(tmp.Key);

            switch (_dataType)
            {
            case DataTypeEnum.RegUwpByte:
                txBox.Text = GetByte(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpInt16:
                txBox.Text = GetInt16(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpUint16:
                txBox.Text = GetUInt16(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpInt32:
                txBox.Text = GetInt32(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpUint32:
                txBox.Text = GetUInt32(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpInt64:
                txBox.Text = GetInt64(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpUint64:
                txBox.Text = GetUInt64(tmp.Value).ToString();
                break;

            case DataTypeEnum.RegUwpSingle:
                txBox.Text = GetSingle(tmp.Value).ToString("G9");
                break;

            case DataTypeEnum.RegUwpDouble:
                txBox.Text = GetDouble(tmp.Value).ToString("G17");
                break;

            default:
                break;
            }
        }
Example #26
0
        public void SetValueData(byte[] dataRaw)
        {
            var tmp = MethodHelpers.SplitDataRaw(dataRaw);

            _timestamp = GetDateTimeOffset(tmp.Key);
            var @bool = GetBoolean(tmp.Value);

            if (@bool)
            {
                cmBox.SelectedIndex = 0;
            }
            else
            {
                cmBox.SelectedIndex = 1;
            }
        }
Example #27
0
        // GET: Lessons/Details/5
        public async Task <ActionResult> Details(Guid?id, string languageFilter)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lesson lesson = await db.Lessons.FindAsync(id);

            if (lesson == null)
            {
                return(HttpNotFound());
            }
            MethodHelpers     methodHelpers = new MethodHelpers();
            TutorialViewModel viewModel     = new TutorialViewModel();

            viewModel.LessionID  = lesson.LessionID;
            viewModel.LessonName = lesson.LessonName;
            viewModel.IssueDate  = lesson.IssueDate;
            viewModel.Subject    = lesson.Subject;
            List <File> files = await db.Files.Where(d => d.LessionID == lesson.LessionID).ToListAsync();

            ViewBag.VideoContent = false;
            ViewBag.IsTranscript = false;
            foreach (var item in files)
            {
                if (item.FileType == "Video")
                {
                    if (languageFilter != null && item.ContentDetails != null)
                    {
                        item.ContentDetails = await methodHelpers.TranslateContent(item.ContentDetails, languageFilter);
                    }
                    ViewBag.VideoContent = true;
                    if (!string.IsNullOrEmpty(item.ContentDetails))
                    {
                        ViewBag.IsTranscript = true;
                    }
                }
            }

            viewModel.Files = files;
            Dictionary <string, string> languageList = methodHelpers.GetSupportedLangs();
            SelectList langs = new SelectList(languageList.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text");

            ViewBag.languageFilter = langs;
            ViewBag.LessionID      = id;
            return(View(viewModel));
        }
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var method    = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.IconNameMethod, typeof(string), Type.EmptyTypes);
            var attribute = type.GetCustomAttribute <IconNameAttribute>();

            methodRemover.SafeRemoveMethod(method);
            if (method is not null)
            {
                FacetUtils.AddFacet(new IconFacetViaMethod(method, specification, attribute?.Value, Logger <IconFacetViaMethod>()));
            }
            else
            {
                FacetUtils.AddFacet(Create(attribute, specification));
            }

            return(metamodel);
        }
Example #29
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, ISpecificationBuilder collection, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var capitalizedName = property.Name;
            var type            = property.DeclaringType;

            var facets = new List <IFacet> {
                new PropertyAccessorFacet(property, collection)
            };

            AddSetFacet(facets, property, collection);

            MethodHelpers.AddHideForSessionFacetNone(facets, collection);
            MethodHelpers.AddDisableFacetAlways(facets, collection);
            MethodHelpers.FindDefaultHideMethod(reflector, facets, property.DeclaringType, MethodType.Object, "PropertyDefault", collection, LoggerFactory);
            MethodHelpers.FindAndRemoveHideMethod(reflector, facets, type, MethodType.Object, capitalizedName, collection, LoggerFactory);
            FacetUtils.AddFacets(facets);
            return(metamodel);
        }
Example #30
0
        protected virtual IEnumerable <MethodDeclarationSyntax> GenerateOperationMethodHeader(
            ILocatedOpenApiElement <OpenApiOperation> operation)
        {
            TypeSyntax requestType  = Context.TypeNameProvider.GetName(operation);
            TypeSyntax responseType = WellKnownTypes.System.Threading.Tasks.TaskT.Name(
                Context.TypeNameProvider.GetName(operation.GetResponseSet()));

            string methodName = Context.NameFormatterSelector.GetFormatter(NameKind.AsyncMethod)
                                .Format(operation.Element.OperationId);

            var methodDeclaration = MethodDeclaration(responseType, methodName)
                                    .AddElementAnnotation(operation, Context.ElementRegistry)
                                    .AddParameterListParameters(
                Parameter(Identifier(OperationMethodGenerator.RequestParameterName))
                .WithType(requestType),
                MethodHelpers.DefaultedCancellationTokenParameter());

            yield return(methodDeclaration);
        }