Ejemplo n.º 1
0
        public void ResolveSingleOrDefault_gets_resolved()
        {
            var mr     = new ManualResolver(CreateResolveContext);
            var result = mr.ResolveSingleOrDefault(MockResolve.Build <String>("42"));

            Assert.Equal("42", result.Value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the start simulation button's click event.
        /// </summary>
        /// <param name="sender">The triggerer object.</param>
        /// <param name="e">The event arguments.</param>
        private void StartNewSimulation_Click(object sender, EventArgs e)
        {
            using (var simulationSettingsForm = new SimulationSettingsForm())
            {
                if (simulationSettingsForm.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                IAmbiguityResolver resolver = null;

                if (ManualResolver.Equals(AmbiguityResolverComboBox.SelectedItem))
                {
                    resolver = new ManualResolver();
                }
                else if (RandomResolver.Equals(AmbiguityResolverComboBox.SelectedItem))
                {
                    resolver = new RandomResolver();
                }

                var stepMethod = GetStepMethod();

                Graph.OnSimulationFinished += OnSimulationFinished;
                Graph.StartSimulation(stepMethod, simulationSettingsForm.GetInputArray(), resolver);

                if (stepMethod == SimulationStepMethod.Timed)
                {
                    TimedStepTimer.Interval = SimulationSpeedTrackBar.Value * 1000;
                    TimedStepTimer.Start();
                }
            }

            SetupUI();
        }
Ejemplo n.º 3
0
        public void Resolve_gets_resolved()
        {
            var mr     = new ManualResolver(CreateResolveContext);
            var result = mr.Resolve(MockResolve.Build <String>("32", "42", "52"));

            Assert.Equal(new[] { "32", "42", "52" }, result);
        }
Ejemplo n.º 4
0
        protected async Task <IEnumerable <T> > ResolveAsync <T>(IResolveBuilder <T, ClientObjectResolveContext> builder)
            where T : ClientObject
        {
            var results = ManualResolver.Resolve(builder);

            await ClientContext.ExecuteQueryAsync();

            return(results);
        }
Ejemplo n.º 5
0
        public void Resolves_most_recent_String()
        {
            var ctx      = Context.PushState("4242").PushState("42");
            var resolver = new ContextStateResolveBuilder <String>();

            var mr   = new ManualResolver(() => new ResolveContext <HarshProvisionerContext>(ctx));
            var many = mr.Resolve(resolver);

            Assert.Single(many, "42");
        }
Ejemplo n.º 6
0
        public void Resolves_most_recent_String()
        {
            var ctx = Context.PushState("4242").PushState("42");
            var resolver = new ContextStateResolveBuilder<String>();

            var mr = new ManualResolver(() => new ResolveContext<HarshProvisionerContext>(ctx));
            var many = mr.Resolve(resolver);

            Assert.Single(many, "42");
        }
Ejemplo n.º 7
0
        public async Task TermSet_resolved_by_id()
        {
            var expected = await EnsureTestTermSet();

            var resolver = ManualResolver.ResolveSingle(
                Resolve.TermStoreSiteCollectionDefault().TermSet().ById(TermSetId),
                ts => ts.Id,
                ts => ts.Name
                );
            await ClientContext.ExecuteQueryAsync();

            var actual = resolver.Value;

            Assert.Equal(TermSetId, actual.Id);
            Assert.Equal(TermSetId.ToString("n"), actual.Name);
        }
Ejemplo n.º 8
0
        public async Task View_get_resolved_by_Url()
        {
            var listAndView = await EnsureTestListAndView();

            var resolvable = ManualResolver.ResolveSingle(
                Resolve.List().ById(listAndView.Item1.Id).View().ByUrl(ViewTitle + ".aspx"),
                v => v.Id
                );

            await ClientContext.ExecuteQueryAsync();

            var view = resolvable.Value;

            Assert.NotNull(view);
            Assert.Equal(listAndView.Item2.Id, view.Id);
        }
Ejemplo n.º 9
0
        public async Task Documents_Title_field_gets_resolved_by_id()
        {
            var list = await CreateList();

            var resolver = ManualResolver.ResolveSingleOrDefault(
                Resolve
                .List().ById(list.Id)
                .Field().ById(HarshBuiltInFieldId.Title)
                );

            await ClientContext.ExecuteQueryAsync();

            var field = resolver.Value;

            Assert.NotNull(field);
            Assert.Equal("Title", await field.EnsurePropertyAvailable(f => f.InternalName));
        }
Ejemplo n.º 10
0
        public async Task Default_Keywords_TermStore_gets_resolved()
        {
            var resolver = ManualResolver.ResolveSingle(Resolve.TermStoreKeywordsDefault());
            await ClientContext.ExecuteQueryAsync();

            var termStore = resolver.Value;

            Assert.NotNull(termStore);

            var expected = TaxonomySession.GetDefaultKeywordsTermStore();

            ClientContext.Load(expected, ts => ts.Id);
            ClientContext.Load(termStore, ts => ts.Id);
            await ClientContext.ExecuteQueryAsync();

            Assert.Equal(expected.Id, termStore.Id);
        }
Ejemplo n.º 11
0
        public void Flattens_enumerable_states()
        {
            var ctx = Context
                      .PushState("123")
                      .PushState(new[] { "42", "4242" });

            var resolver = new ContextStateResolveBuilder <String>();

            var mr   = new ManualResolver(() => new ResolveContext <HarshProvisionerContext>(ctx));
            var many = mr.Resolve(resolver);

            Assert.Collection(
                many,
                x => Assert.Equal("42", x),
                x => Assert.Equal("4242", x),
                x => Assert.Equal("123", x)
                );
        }
Ejemplo n.º 12
0
        public void Flattens_enumerable_states()
        {
            var ctx = Context
                .PushState("123")
                .PushState(new[] { "42", "4242" });

            var resolver = new ContextStateResolveBuilder<String>();

            var mr = new ManualResolver(() => new ResolveContext<HarshProvisionerContext>(ctx));
            var many = mr.Resolve(resolver);

            Assert.Collection(
                many,
                x => Assert.Equal("42", x),
                x => Assert.Equal("4242", x),
                x => Assert.Equal("123", x)
            );
        }
Ejemplo n.º 13
0
        protected override async Task OnProvisioningAsync()
        {
            if (ExistingField.HasValue)
            {
                Field = ExistingField.Value;

                WriteOutput(
                    Result.AlreadyExists(FieldIdentifier, Field)
                    );
            }
            else
            {
                ValidateMandatoryWhenCreatingParameters();

                Logger.Information("Adding field {InternalName}, id {Id}", InternalName, Id);

                var schemaXml = BuildSchemaXml();

                TargetFieldCollection.AddFieldAsXml(
                    schemaXml.ToString(),
                    AddToDefaultView,
                    AddFieldOptions
                    );

                // cannot use the instance returned from AddFieldAsXml,
                // as that is always of type Field, not the actual subtype.

                var reResolvedField = ManualResolver.ResolveSingle(
                    Resolve.Field().ById(Id)
                    );

                await ClientContext.ExecuteQueryAsync();

                Field = reResolvedField.Value;

                WriteOutput(
                    Result.Added(FieldIdentifier, Field)
                    );
            }
        }
Ejemplo n.º 14
0
        public async Task List_gets_resolved_by_url()
        {
            ClientContext.Load(Web, w => w.ServerRelativeUrl);
            var list = await CreateList(l => l.RootFolder.ServerRelativeUrl);

            var url = HarshUrl.GetRelativeTo(list.RootFolder.ServerRelativeUrl, Web.ServerRelativeUrl);

            var results = ManualResolver.Resolve(
                Resolve.List().ByUrl(url)
                );

            await ClientContext.ExecuteQueryAsync();

            var resolvedList = Assert.Single(results);

            Assert.NotNull(resolvedList);
            Assert.Equal(
                list.RootFolder.ServerRelativeUrl,
                resolvedList.RootFolder.ServerRelativeUrl,
                StringComparer.OrdinalIgnoreCase
                );
        }