예제 #1
0
 public TestLevel(int width, int height) : base(
         new LevelLayout(width, height,
                         new List <BlockingTileSpawnInfo>()
 {
     new BlockingTileSpawnInfo() { GridPosition = Vector2Int.one, Health = 50f },
     new BlockingTileSpawnInfo() { GridPosition = new Vector2Int(1, 2), Health = 50f },
     new BlockingTileSpawnInfo() { GridPosition = new Vector2Int(2, 2), Health = 50f },
     new BlockingTileSpawnInfo() { GridPosition = new Vector2Int(3, 4), Health = 50f },
     new BlockingTileSpawnInfo() { GridPosition = new Vector2Int(3, 3), Health = 50f }
 },
                         new List <MoveableTileSpawnInfo>()
 {
     new MoveableTileSpawnInfo() { GridPosition = Vector2Int.zero, Value = 2 },
     new MoveableTileSpawnInfo() { GridPosition = Vector2Int.up, Value = 2 },
     new MoveableTileSpawnInfo() { GridPosition = Vector2Int.right, Value = 1 },
     new MoveableTileSpawnInfo() { GridPosition = new Vector2Int(3, 2), Value = 2 },
     new MoveableTileSpawnInfo() { GridPosition = new Vector2Int(4, 4), Value = 3 },
     new MoveableTileSpawnInfo() { GridPosition = new Vector2Int(2, 4), Value = 0 }
 }),
         new DefaultValueAndColorGenerator(new ColorPickerValueAsIndex(new Color[] { Color.red, Color.green, Color.blue, Color.yellow }), new DirectionMapping(-2, 1, 2, -1)),
         ConditionFactory.BuildCondition(typeof(NumberOfMoveableTilesLeftWinCondition), $"{typeof(NumberOfMoveableTilesLeftWinCondition)}\n1"),
         new NumberOfMovesLoseCondition(5),
         new DifferenceOfNMergeRule(1),
         new SpawnBlockerMergeEffect())
 {
 }
예제 #2
0
        public ActionResult Add()
        {
            var model = new CarAddViewModel();

            var carRepo           = GuildRepositoryFactory.GetRepository();
            var makesRepo         = MakeFactory.GetRepository();
            var modelRepo         = ModelFactory.GetRepository();
            var typesRepo         = ConditionFactory.GetRepository();
            var bodyStylesRepo    = BodyStyleFactory.GetRepository();
            var transmissionsRepo = TransmissionFactory.GetRepository();
            var extColorsRepo     = ExteriorColorFactory.GetRepository();
            var intColorsRepo     = InteriorColorFactory.GetRepository();

            CarAddViewModel viewModel = new CarAddViewModel
            {
                Makes          = makesRepo.GetMakes(),
                Models         = modelRepo.GetModels(),
                Types          = typesRepo.GetConditions(),
                BodyStyles     = bodyStylesRepo.GetBodyStyles(),
                Transmissions  = transmissionsRepo.GetTransmissions(),
                ExteriorColors = extColorsRepo.GetExteriorColors(),
                InteriorColors = intColorsRepo.GetInteriorColors()
            };

            return(View(viewModel));
        }
예제 #3
0
 public void Collapse()
 {
     if (!Current.IsEnabled || ExpandCollapseState != ExpandCollapseState.Expanded)
     {
         return;
     }
     if (FrameworkType == FrameworkType.WinForms)
     {
         // WinForms
         var openButton = FindFirstChild(ConditionFactory.ByControlType(ControlType.Button)).AsButton();
         if (IsEditable)
         {
             // WinForms editable combo box only closes on click and not on invoke
             openButton.Click(false);
         }
         else
         {
             openButton.Invoke();
         }
     }
     else
     {
         // WPF
         var ecp = PatternFactory.GetExpandCollapsePattern();
         if (ecp != null)
         {
             ecp.Collapse();
         }
     }
     Helpers.WaitUntilInputIsProcessed();
 }
        /// <summary>
        /// Creates the ConditionLookup which is of the format source -> {target -> CondInfo}
        /// Populates the DependencyGraph which is of the format target > {source}.
        /// </summary>
        /// <returns> ConditionLookup. </returns>
        private Dictionary <int, Dictionary <int, CondInfo> > CreateConditionLookupAndPopulateDependencyGraph()
        {
            // Get list of the conditions that are on the execution flow
            ConditionFactory cf    = this.TestSet.ConditionFactory as ConditionFactory;
            List             conds = cf.NewList(string.Empty);
            Dictionary <int, Dictionary <int, CondInfo> > conditionLookup = new Dictionary <int, Dictionary <int, CondInfo> >();

            // Loop through the list of conditions to populate conditions list & create a dependency matrix
            //    source -> {target -> CondInfo}
            //    target -> {source}
            foreach (ICondition c in conds)
            {
                int source   = int.Parse($"{c.Source}");
                int target   = int.Parse($"{c.Target}");
                int condType = int.Parse(c.Value.ToString());

                // only add condition if both source and target is in our dictionary
                // there are phantom conditions recorded =.=
                if (this.testCaseDict.ContainsKey(source) && this.testCaseDict.ContainsKey(target))
                {
                    // Console.WriteLine("{0} : [{1} -> {2}]", c.ID, this.testCaseDict[source].Name, this.testCaseDict[target].Name);

                    // Populating Dependency Graph
                    if (this.testCaseCondDependencyGraph.ContainsKey(target))
                    {
                        this.testCaseCondDependencyGraph[target].Add(source);
                    }
                    else
                    {
                        this.testCaseCondDependencyGraph[target] = new HashSet <int>()
                        {
                            source
                        };
                    }

                    if (conditionLookup.ContainsKey(source))
                    {
                        conditionLookup[source].Add(target, new CondInfo()
                        {
                            CondType = condType, CondID = int.Parse($"{c.ID}")
                        });
                    }
                    else
                    {
                        conditionLookup[source] = new Dictionary <int, CondInfo>
                        {
                            {
                                target, new CondInfo()
                                {
                                    CondType = condType,
                                    CondID   = int.Parse($"{c.ID}"),
                                }
                            },
                        };
                    }
                }
            }

            return(conditionLookup);
        }
예제 #5
0
        public void GetCondition_Returns_Condition_From_Condition_Metadata()
        {
            var condition = ConditionFactory.GetCondition(ConditionMetadata);

            Assert.NotNull(condition);
            Assert.True(condition is XmlFileQueryCondition);
        }
예제 #6
0
파일: ComboBox.cs 프로젝트: jmaxxz/FlaUI
 public void Collapse()
 {
     if (!Properties.IsEnabled || ExpandCollapseState != ExpandCollapseState.Expanded)
     {
         return;
     }
     if (FrameworkType == FrameworkType.WinForms)
     {
         // WinForms
         var openButton = FindFirstChild(ConditionFactory.ByControlType(ControlType.Button)).AsButton();
         if (IsEditable)
         {
             // WinForms editable combo box only closes on click and not on invoke
             openButton.Click();
         }
         else
         {
             openButton.Invoke();
         }
     }
     else
     {
         // WPF
         var ecp = Patterns.ExpandCollapse.PatternOrDefault;
         ecp?.Collapse();
     }
     Helpers.WaitUntilResponsive(this);
 }
예제 #7
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="patchManager">Manages loaded patches.</param>
 /// <param name="conditionFactory">Handles constructing, permuting, and updating conditions.</param>
 /// <param name="monitor">Encapsulates monitoring and logging.</param>
 /// <param name="updateContext">A callback which immediately updates the current condition context.</param>
 public CommandHandler(PatchManager patchManager, ConditionFactory conditionFactory, IMonitor monitor, Action updateContext)
 {
     this.PatchManager     = patchManager;
     this.ConditionFactory = conditionFactory;
     this.Monitor          = monitor;
     this.UpdateContext    = updateContext;
 }
예제 #8
0
        public virtual void GrantNotificationPermission(AmazonSQSClient sqsClient, string queueArn, string queueUrl,
                                                        string topicArn)
        {
            // Create a policy to allow the queue to receive notifications from the SNS topic
            var policy = new Policy("SubscriptionPermission")
            {
                Statements =
                {
                    new Statement(Statement.StatementEffect.Allow)
                    {
                        Actions    = { SQSActionIdentifiers.SendMessage },
                        Principals ={ new Principal("*")                                },
                        Conditions ={ ConditionFactory.NewSourceArnCondition(topicArn)  },
                        Resources  = { new Resource(queueArn)           }
                    }
                }
            };

            var attributes = new Dictionary <string, string>();

            attributes.Add("Policy", policy.ToJson());

            // Create the request to set the queue attributes for policy
            var setQueueAttributesRequest = new SetQueueAttributesRequest
            {
                QueueUrl   = queueUrl,
                Attributes = attributes
            };

            // Set the queue policy
            sqsClient.SetQueueAttributes(setQueueAttributesRequest);
        }
예제 #9
0
        public void InitRec()
        {
            Process[] processes = Process.GetProcessesByName("FormsToControl");

            foreach (Process p in processes)
            {
                var app = FlaUI.Core.Application.Attach(p);

                using (var automation = new UIA3Automation())
                {
                    wd = app.GetMainWindow(automation);
                    var children        = wd.FindAllChildren();
                    ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary());

                    foreach (var child in children)
                    {
                        if (child.Name == "do it")
                        {
                            //richTextBox1.Text += $"\nctl loc: {child.BoundingRectangle.Location}";
                            //richTextBox1.Text += $"\nctl right: {child.BoundingRectangle.Right}";
                            //richTextBox1.Text += $"\nctl top: {child.BoundingRectangle.Top}";
                            //richTextBox1.Text += $"\nctl bottom: {child.BoundingRectangle.Bottom}";

                            rec.Location = child.BoundingRectangle.Location;
                            rec.Width    = child.BoundingRectangle.Right - child.BoundingRectangle.Location.X;
                            rec.Height   = child.BoundingRectangle.Bottom - child.BoundingRectangle.Location.Y;
                        }
                    }
                }
            }
        }
예제 #10
0
        public string SetSqsPolicyForSnsPublish(Uri queueUrl, string queueArn, string mytopicArn)
        {
            queueUrl.Requires("queueUrl").IsNotNull();
            queueArn.Requires("queueArn").IsNotNullOrWhiteSpace();
            mytopicArn.Requires("mytopicArn").IsNotNullOrWhiteSpace();

            var sqsPolicy = new Policy().WithStatements(
                new Statement(Statement.StatementEffect.Allow)
                .WithResources(new Resource(queueArn))
                .WithPrincipals(Principal.AllUsers)
                .WithActionIdentifiers(SQSActionIdentifiers.SendMessage)
                .WithConditions(ConditionFactory.NewCondition(ConditionFactory.ArnComparisonType.ArnEquals,
                                                              ConditionSourceArn, mytopicArn)));

            var attributes = new Dictionary <string, string>
            {
                { QueueAttributeName.Policy, sqsPolicy.ToJson() }
            };

            var setQueueAttributesRequest = new SetQueueAttributesRequest(queueUrl.AbsoluteUri, attributes);

            using (var sqs = amazonSqsFactory())
            {
                var response = sqs.SetQueueAttributes(setQueueAttributesRequest);
                return(response.ResponseMetadata.RequestId);
            }
        }
예제 #11
0
        /// <summary>
        /// Helper method for AuthorizeS3ToPublishAsync()
        /// </summary>
        /// <param name="attributes"></param>
        /// <param name="topicArn"></param>
        /// <param name="bucket"></param>
        /// <param name="policy"></param>
        /// <param name="statement"></param>
        private static void GetNewPolicyAndStatementForTopicAttributes(Dictionary <string, string> attributes, string topicArn, string bucket, out Policy policy, out Statement statement)
        {
            if (attributes.ContainsKey("Policy") && !string.IsNullOrEmpty(attributes["Policy"]))
            {
                policy = Policy.FromJson(attributes["Policy"]);
            }
            else
            {
                policy = new Policy();
            }

            var sourceArn = string.Format(CultureInfo.InvariantCulture, "arn:aws:s3:*:*:{0}", bucket);

            statement = new Statement(Statement.StatementEffect.Allow);
            statement.Actions.Add(SNSActionIdentifiers.Publish);
            statement.Resources.Add(new Resource(topicArn));
            statement.Principals.Add(new Principal("*"));
            statement.Conditions.Add(ConditionFactory.NewSourceArnCondition(sourceArn));

            // If the arn doesn't have the required tokens then it is most likely be called from a mock or fake AWS service.
            // Since this is an existing method we don't want to introduce a new exception. So if there is no account id then
            // don't add the extra condition.
            if (Arn.TryParse(topicArn, out Arn arn) && !string.IsNullOrEmpty(arn.AccountId))
            {
                statement.Conditions.Add(ConditionFactory.NewCondition(ConditionFactory.StringComparisonType.StringEquals, ConditionFactory.SOURCE_ACCOUNT_KEY, arn.AccountId));
            }
        }
예제 #12
0
        public void GetConditionIdsInGroup_None_Test()
        {
            var factory = new ConditionFactory();
            var ids     = factory.GetConditionIdsInGroup(ConditionGroup.None);

            Assert.AreEqual(18, ids.Count());
            Assert.IsFalse(ids.Any(i => i == EntityIds.FRIENDLY_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.HELPFUL_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.HOSTILE_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.INDIFFERENT_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.UNFRIENDLY_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.DOOMED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.DYING_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.UNCONSCIOUS_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.WOUNDED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.HIDDEN_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.OBSERVED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.UNDETECTED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.UNNOTICED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.CLUMSY_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.DRAINED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.ENFEEBLED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.STUPEFIED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.BLINDED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.CONCEALED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.DAZZLED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.DEAFENED_CONDITION_ID));
            Assert.IsFalse(ids.Any(i => i == EntityIds.INVISIBLE_CONDITION_ID));
        }
예제 #13
0
        public void TestBasicControls()
        {
            var application     = FlaUI.Core.Application.Launch(@"C:\Data\Visual Studio Workspace\FlaUiPractice\FlaUIPractice\BankSystem\bin\Release\BankSystem.exe");
            var automation      = new UIA3Automation();
            var mainWindow      = application.GetMainWindow(automation);
            ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary());

            mainWindow.FindFirstDescendant(cf.ByName("Registration")).AsButton().Click();
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InFName")).AsTextBox().Enter("Yadagiri");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InLName")).AsTextBox().Enter("Reddy");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InAge")).AsComboBox().Select(4).Click();
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InCountry")).AsComboBox().Select("India").Click();
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InPhone")).AsTextBox().Enter("9876543210");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InEmail")).AsTextBox().Enter("*****@*****.**");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InPass")).AsTextBox().Enter("12345");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("InCard")).AsTextBox().Enter("456378963215");
            mainWindow.FindFirstDescendant(cf.ByAutomationId("VipCheck")).AsCheckBox().Click();
            mainWindow.FindFirstDescendant(cf.ByName("Ok")).AsButton().Click();
            var congratulationsWindow = mainWindow.FindFirstDescendant(cf.ByName("Congratulations")).AsWindow();

            Assert.IsNotNull(congratulationsWindow);
            congratulationsWindow.FindFirstDescendant(cf.ByName("OK")).AsButton().Click();
            mainWindow.FindFirstDescendant(cf.ByName("Exit")).AsButton().Click();
            var exitWindow = mainWindow.FindFirstDescendant(cf.ByName("Exit")).AsWindow();

            exitWindow.FindFirstDescendant(cf.ByName("Yes")).AsButton().Click();
        }
예제 #14
0
        public void GetApplicablePermutationsForTheseConditions()
        {
            // arrange
            ConditionFactory       factory = new ConditionFactory();
            HashSet <ConditionKey> keys    = new HashSet <ConditionKey> {
                ConditionKey.DayOfWeek, ConditionKey.Season
            };
            ConditionDictionary conditions = factory.BuildEmpty();

            // act
            IEnumerable <IDictionary <ConditionKey, string> > permutations = factory.GetApplicablePermutationsForTheseConditions(keys, conditions);

            // assert
            IEnumerable <string> actual   = permutations.Select(permutation => "(" + this.SortAndCommaDelimit(permutation.Select(p => $"{p.Key}:{p.Value}")) + ")");
            List <string>        expected = new List <string>();

            foreach (DayOfWeek dayOfWeek in this.DaysOfWeek)
            {
                foreach (string season in this.Seasons)
                {
                    expected.Add($"({ConditionKey.DayOfWeek}:{dayOfWeek}, {ConditionKey.Season}:{season})");
                }
            }

            this.SortAndCommaDelimit(actual).Should().Be(this.SortAndCommaDelimit(expected));
        }
예제 #15
0
        public void GetPermutations()
        {
            // arrange
            InvariantDictionary <InvariantHashSet> values = new InvariantDictionary <InvariantHashSet>
            {
                ["a"] = new InvariantHashSet {
                    "a1", "a2", "a3"
                },
                ["b"] = new InvariantHashSet {
                    "b1", "b2", "b3"
                },
                ["c"] = new InvariantHashSet {
                    "c1", "c2", "c3"
                }
            };

            // act
            IEnumerable <InvariantDictionary <string> > permutations = new ConditionFactory().GetPermutations(values);

            // assert
            IEnumerable <string> actual   = permutations.Select(permutation => "(" + this.SortAndCommaDelimit(permutation.Values.OrderBy(p => p)) + ")");
            IList <string>       expected = new List <string>();

            for (int a = 1; a <= 3; a++)
            {
                for (int b = 1; b <= 3; b++)
                {
                    for (int c = 1; c <= 3; c++)
                    {
                        expected.Add($"(a{a}, b{b}, c{c})");
                    }
                }
            }
            this.SortAndCommaDelimit(actual).Should().Be(this.SortAndCommaDelimit(expected));
        }
예제 #16
0
        public void TestMethod1()
        {
            var application = FlaUI.Core.Application.Launch("Notepad.exe");

            var main           = application.GetMainWindow(new UIA3Automation());
            ConditionFactory c = new ConditionFactory(new UIA3PropertyLibrary());
            var a = main.FindFirstDescendant();

            a.AsTextBox().Enter("hiiii");

            /*var me=main.FindChildAt(3).AsMenu();
             * me.DrawHighlight();
             * me.Items[0].Invoke();
             */Keyboard.Pressing(VirtualKeyShort.CONTROL);
            Keyboard.Press(VirtualKeyShort.KEY_S);
            Keyboard.Release(VirtualKeyShort.CONTROL);
            var g = main.FindFirstDescendant(c.ByControlType(FlaUI.Core.Definitions.ControlType.Edit));

            Keyboard.Press(VirtualKeyShort.BACK);
            Keyboard.Press(VirtualKeyShort.KEY_H);
            Keyboard.Press(VirtualKeyShort.KEY_I);

            Keyboard.Press(VirtualKeyShort.ENTER);

            Keyboard.TypeSimultaneously(VirtualKeyShort.CONTROL, VirtualKeyShort.KEY_A);
            Keyboard.TypeSimultaneously(VirtualKeyShort.CONTROL, VirtualKeyShort.KEY_H);
        }
예제 #17
0
 public void GetText()
 {
     var window = App.GetMainWindow(Uia3Automation);
     var label = window.FindFirst(TreeScope.Descendants, ConditionFactory.ByText("Test Label")).AsLabel();
     Assert.That(label, Is.Not.Null);
     Assert.That(label.Text, Is.EqualTo("Test Label"));
 }
예제 #18
0
파일: MenuTests.cs 프로젝트: csuffyy/FlaUI
        public void TestMenuWithSubMenus()
        {
            var window = App.GetMainWindow(Uia3Automation);
            var menu   = window.FindFirst(TreeScope.Children, ConditionFactory.Menu()).AsMenu();

            Assert.That(menu, Is.Not.Null);
            var items = menu.MenuItems;

            Assert.That(items, Has.Length.EqualTo(2));
            Assert.That(items[0].Current.Name, Is.EqualTo("File"));
            Assert.That(items[1].Current.Name, Is.EqualTo("Edit"));
            var subitems1 = items[0].SubMenuItems;

            Assert.That(subitems1, Has.Length.EqualTo(1));
            Assert.That(subitems1[0].Current.Name, Is.EqualTo("Exit"));
            var subitems2 = items[1].SubMenuItems;

            Assert.That(subitems2, Has.Length.EqualTo(2));
            Assert.That(subitems2[0].Current.Name, Is.EqualTo("Copy"));
            Assert.That(subitems2[1].Current.Name, Is.EqualTo("Paste"));
            var subsubitems1 = subitems2[0].SubMenuItems;

            Assert.That(subsubitems1, Has.Length.EqualTo(2));
            Assert.That(subsubitems1[0].Current.Name, Is.EqualTo("Plain"));
            Assert.That(subsubitems1[1].Current.Name, Is.EqualTo("Fancy"));
        }
예제 #19
0
        /// <summary>
        /// Gets the context menu by a given <see cref="FrameworkType"/>.
        /// </summary>
        public Menu GetContextMenuByFrameworkType(FrameworkType frameworkType)
        {
            if (frameworkType == FrameworkType.Win32)
            {
                // The main menu is directly under the desktop with the name "Context" or in a few cases "System"
                var desktop       = FrameworkAutomationElement.Automation.GetDesktop();
                var nameCondition = ConditionFactory.ByName("Context").Or(ConditionFactory.ByName("System"));
                var ctxMenu       = desktop.FindFirstChild(cf => cf.ByControlType(ControlType.Menu).And(nameCondition)).AsMenu();
                if (ctxMenu != null)
                {
                    ctxMenu.IsWin32Menu = true;
                    return(ctxMenu);
                }
            }
            var mainWindow = GetMainWindow();

            if (frameworkType == FrameworkType.WinForms)
            {
                var ctxMenu = mainWindow.FindFirstChild(cf => cf.ByControlType(ControlType.Menu).And(cf.ByName("DropDown")));
                return(ctxMenu.AsMenu());
            }
            if (frameworkType == FrameworkType.Wpf)
            {
                // In WPF, there is a window (Popup) where the menu is inside
                var popup   = Popup;
                var ctxMenu = popup.FindFirstChild(cf => cf.ByControlType(ControlType.Menu));
                return(ctxMenu.AsMenu());
            }
            // No menu found
            return(null);
        }
예제 #20
0
        public void GetConditions_Returns_Conditions_From_Conditions_Metadata()
        {
            var conditions = ConditionFactory.GetConditions(ConditionGroupMetadata.Conditions).ToList();

            Assert.True(conditions.Count == 2);
            Assert.True(conditions.All(c => c.GetType() == typeof(XmlFileQueryCondition)));
        }
예제 #21
0
        public static AutomationSearchCondition ByClassName(string className)
        {
            var asc = new AutomationSearchCondition();

            asc._conditions.Add(ConditionFactory.ByClassName(className));
            return(asc);
        }
예제 #22
0
        public ActionResult Index()
        {
            CarViewModel model = new CarViewModel();

            var carRepo           = GuildRepositoryFactory.GetRepository();
            var makesRepo         = MakeFactory.GetRepository();
            var modelRepo         = ModelFactory.GetRepository();
            var typesRepo         = ConditionFactory.GetRepository();
            var bodyStylesRepo    = BodyStyleFactory.GetRepository();
            var transmissionsRepo = TransmissionFactory.GetRepository();
            var extColorsRepo     = ExteriorColorFactory.GetRepository();
            var intColorsRepo     = InteriorColorFactory.GetRepository();

            List <Car> carList = carRepo.GetAllCars();

            List <CarViewModel> carVMList = carList.Select(x => new CarViewModel
            {
                CarID         = x.CarID,
                MakeID        = x.MakeID,
                MakeName      = makesRepo.GetMakeById(x.MakeID).MakeName,
                ModelID       = x.ModelID,
                ModelName     = modelRepo.GetModelById(x.ModelID).ModelName,
                Year          = x.Year,
                MSRP          = x.MSRP,
                SalePrice     = x.SalePrice,
                ImageFileName = x.Photo
            }).ToList();

            /*foreach (var car in carList)
             * {
             * }*/

            return(View(carVMList));
        }
예제 #23
0
        public string GetDaysFor(DayOfWeek dayOfWeek)
        {
            // act
            IEnumerable <int> days = new ConditionFactory().GetDaysFor(dayOfWeek);

            // assert
            return(this.CommaDelimit(days));
        }
예제 #24
0
        public void GetValidValues(ConditionKey condition)
        {
            // act
            IEnumerable <string> values = new ConditionFactory().GetValidValues(condition);

            // assert
            this.SortAndCommaDelimit(values).Should().Be(this.CommaDelimitedValues[condition]);
        }
예제 #25
0
        public void GetValidConditions()
        {
            // act
            IEnumerable <ConditionKey> conditions = new ConditionFactory().GetValidConditions();

            // assert
            this.SortAndCommaDelimit(conditions).Should().Be(this.SortAndCommaDelimit(Enum.GetValues(typeof(ConditionKey)).Cast <ConditionKey>()));
        }
예제 #26
0
 protected virtual IEnumerable <IMatchingCondition> BuildConditions
 (
     fo.DicomDataset request,
     ConditionFactory condFactory
 )
 {
     return(condFactory.ProcessDataSet(request));
 }
예제 #27
0
 protected AutomationBase(IPropertyLibray propertyLibrary, IEventLibrary eventLibrary, IPatternLibrary patternLibrary)
 {
     PropertyLibrary  = propertyLibrary;
     EventLibrary     = eventLibrary;
     PatternLibrary   = patternLibrary;
     ConditionFactory = new ConditionFactory(propertyLibrary);
     OverlayManager   = new OverlayManager();
 }
예제 #28
0
        /// <summary>
        /// Closes the given window and invokes the "Don't save" button
        /// </summary>
        public static void CloseWindowWithDontSave(Window window)
        {
            window.Close();
            Helpers.WaitUntilInputIsProcessed();
            var modal          = window.GetModalWindows();
            var dontSaveButton = modal[0].FindFirst(TreeScope.Descendants, ConditionFactory.ByAutomationId("CommandButton_7")).AsButton();

            dontSaveButton.Invoke();
        }
예제 #29
0
        public void NestedComparisonTest()
        {
            var wrapperA = new FloatClassWrapper <Vector2> .FloatWrapperA <Tuple <string, string>, float>(2);

            FloatWrapperB wrapperB = new FloatWrapperB(2);
            Dictionary <string, object> objDictionary = new Dictionary <string, object>();

            objDictionary.Add("floatWrapper_a", wrapperA);
            objDictionary.Add("floatWrapper_b", wrapperB);
            var schema = FloatComparisonNestedSchemata();

            var condGate = new ConditionFactory(objDictionary).Build(schema);

            Assert.True(condGate.Met());
            schema.conditionType = ConditionType.And;
            condGate             = new ConditionFactory(objDictionary).Build(schema);
            Assert.False(condGate.Met());
            wrapperB.f = 1;
            Assert.True(condGate.Met());

            Stopwatch watch = new Stopwatch();

            condGate.Met(); // clearing for cache and JiT
            watch.Start();
            for (int i = 0; i < 1000000; i++)
            {
                condGate.Met();
            }
            watch.Stop();
            Console.WriteLine("Elapsed milliseconds for dynamically compiled method: " + watch.ElapsedMilliseconds);
            ICondition hardCodedConditionGate = new ConditionsGate(ConditionType.And, new ConditionAtom(() => wrapperA.f >= 2, false), new ConditionAtom(() => wrapperB.f < 2, false));

            watch.Reset();
            hardCodedConditionGate.Met(); // clearing cache and JiT
            watch.Start();
            for (int i = 0; i < 1000000; i++)
            {
                hardCodedConditionGate.Met();
            }
            watch.Stop();
            Console.WriteLine("Elapsed milliseconds for hard-coded delegate: " + watch.ElapsedMilliseconds);

            dynamic    dyn_wrapperA         = wrapperA;
            dynamic    dyn_wrapperB         = wrapperB;
            ICondition dynamicConditionGate = new ConditionsGate(ConditionType.And, new ConditionAtom(() => dyn_wrapperA.f >= 2, false), new ConditionAtom(() => dyn_wrapperB.f < 2, false));

            watch.Reset();
            dynamicConditionGate.Met(); // clearing cache and JiT
            watch.Start();
            for (int i = 0; i < 1000000; i++)
            {
                dynamicConditionGate.Met();
            }
            watch.Stop();
            Console.WriteLine("Elapsed milliseconds for dynamically-typed, hard-coded delegate: " + watch.ElapsedMilliseconds);
        }
예제 #30
0
        /// <summary>
        /// Add statement to the policy that gives the sns topic access to send a message to the queue.
        /// </summary>
        /// <param name="policy"></param>
        /// <param name="topicArn"></param>
        /// <param name="sqsQueueArn"></param>
        private static void AddSQSPermission(Policy policy, string topicArn, string sqsQueueArn)
        {
            Statement statement = new Statement(Statement.StatementEffect.Allow);

            statement.Actions.Add(SQSActionIdentifiers.SendMessage);
            statement.Resources.Add(new Resource(sqsQueueArn));
            statement.Conditions.Add(ConditionFactory.NewSourceArnCondition(topicArn));
            statement.Principals.Add(new Principal("*"));
            policy.Statements.Add(statement);
        }
 public void Setup()
 {
     _factory = new ConditionFactory();
 }
 internal ConditionParser(ConditionFactory factory, ConditionTokenBuffer buffer)
 {
     _factory = factory;
     _tokens = buffer;
 }
 internal InitializationContext(IEnumerable<Assembly> assemblies, IInternalLogger internalLogger)
 {
     _formatPatternFactory = new FormatPatternFactory(new FormatRendererTypeMap(assemblies));
     _conditionFactory = new ConditionFactory(assemblies);
     _internalLogger = internalLogger;
 }