Пример #1
0
        public virtual void BogusName()
        {
            // Act
            Container.RegisterType <ObjectWithThreeFields>(
                Resolve.Field("BogusName"));

            // Act
            _ = Container.Resolve <ObjectWithThreeFields>();
        }
        public void ResolveOverAttribute()
        {
            // Setup
            Container.RegisterType <ObjectWithAttributes>(
                Resolve.Field(nameof(ObjectWithAttributes.Dependency)));

            // Act
            var result = Container.Resolve <ObjectWithAttributes>();

            // Verify
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Dependency);
            Assert.AreEqual(result.Dependency, Name);
            Assert.IsNull(result.Optional);
        }
Пример #3
0
        public void ByNameInDerived()
        {
            // Setup
            Container.RegisterType <ObjectWithFourFields>(
                Resolve.Field(nameof(ObjectWithFourFields.Field)));

            // Act
            var result = Container.Resolve <ObjectWithFourFields>();

            // Verify
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Field);
            Assert.IsInstanceOfType(result.Field, typeof(object));
            Assert.AreEqual(result.Name, Name);
            Assert.IsNotNull(result.Container);
        }
Пример #4
0
        public async Task Title_gets_resolved_with_InternalName()
        {
            var ctx = new ClientObjectResolveContext(Context);

            ctx.Include <Field>(
                f => f.InternalName,
                f => f.Description
                );

            Field = Resolve.Field().ById(HarshBuiltInFieldId.Title);

            Binder.Bind(this, () => ctx);

            await ctx.ProvisionerContext.ClientContext.ExecuteQueryAsync();

            var field = Field.Value;

            Assert.NotNull(field);
            Assert.True(field.IsPropertyAvailable(f => f.Description));
            Assert.True(field.IsPropertyAvailable(f => f.InternalName));
            Assert.Equal("Title", field.InternalName);
        }
Пример #5
0
 public void None()
 {
     // Act
     Container.RegisterType <ObjectWithThreeFields>(
         Resolve.Field("Bogus Name"));
 }
Пример #6
0
        public async Task Child_fieldref_get_added()
        {
            var fieldId = Guid.NewGuid();

            var field = new HarshField()
            {
                Id           = fieldId,
                InternalName = fieldId.ToString("n"),
                Type         = FieldType.Text,
            };

            var ct = new HarshContentType()
            {
                Id          = _id,
                Name        = _guid,
                Description = _guid,
                Group       = Group,
                Children    =
                {
                    new HarshFieldRef()
                    {
                        Fields = Resolve.Field().ById(fieldId),
                    },
                }
            };

            try
            {
                await field.ProvisionAsync(Context);

                await ct.ProvisionAsync(Context);

                var cto = LastObjectOutput <ContentType>();

                Assert.True(cto.ObjectAdded);
                Assert.False(cto.Object.IsNull());

                var links = ClientContext.LoadQuery(
                    cto.Object.FieldLinks
                    .Where(fl => fl.Id == fieldId)
                    .Include(
                        fl => fl.Name,
                        fl => fl.Id
                        )
                    );

                await ClientContext.ExecuteQueryAsync();

                var link = Assert.Single(links);

                Assert.NotNull(link);
                Assert.Equal(fieldId, link.Id);
                Assert.Equal(field.InternalName, link.Name);
            }
            finally
            {
                try
                {
                    Web.ContentTypes.GetById(_id.ToString()).DeleteObject();
                }
                finally
                {
                    Web.Fields.GetById(fieldId).DeleteObject();
                }
            }
        }