GetField() публичный Метод

Gets the field.
public GetField ( Sitecore field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context ) : object
field Sitecore The field.
config Glass.Mapper.Sc.Configuration.SitecoreFieldConfiguration The config.
context SitecoreDataMappingContext The context.
Результат object
        public void GetField_FieldContainsData_StreamIsReturned()
        {
            //Assign
            var fieldValue = "";

            var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldStreamMapper/GetField");
            var field = item.Fields[FieldName];
            string expected = "hello world";

            var stream = new MemoryStream(Encoding.UTF8.GetBytes(expected));
            var mapper = new SitecoreFieldStreamMapper();

            using (new ItemEditing(item, true))
            {
                field.SetBlobStream(stream);
            }

            //Act
            var result = mapper.GetField(field, null, null) as Stream;

            //Assert
            var reader = new StreamReader(result);

            var resultStr = reader.ReadToEnd();
            Assert.AreEqual(expected, resultStr);
        }
        public void GetField_FieldContainsDataTestConnectionLimit_StreamIsReturned()
        {
            //Assign
            var fieldValue = "";

            var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldStreamMapper/GetField");
            var field = item.Fields[FieldName];
            string expected = "hello world";

            var stream = new MemoryStream(Encoding.UTF8.GetBytes(expected));
            var mapper = new SitecoreFieldStreamMapper();

            using (new ItemEditing(item, true))
            {
                field.SetBlobStream(stream);
            }

            //Act
            var results = new List<Stream>();

            for (int i = 0; i < 1000; i++)
            {
                var result = mapper.GetField(field, null, null) as Stream;
                results.Add(result);
            }

            //Assert
            Assert.AreEqual(1000, results.Count);
        }
        public void GetField_FieldContainsData_StreamIsReturned()
        {
            //Assign
            var templateId = ID.NewID;
            var targetId = ID.NewID;
            var fieldName = "Field";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    {fieldName, ""}
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),

            })
            {
                var fieldValue = "";

                var item = database.GetItem("/sitecore/content/Target");
                var field = item.Fields[fieldName];
                string expected = "hello world";

                var stream = new MemoryStream(Encoding.UTF8.GetBytes(expected));
                var mapper = new SitecoreFieldStreamMapper();

                using (new ItemEditing(item, true))
                {
                    field.SetBlobStream(stream);
                }

                //Act
                var result = mapper.GetField(field, null, null) as Stream;

                //Assert
                var reader = new StreamReader(result);

                var resultStr = reader.ReadToEnd();
                Assert.AreEqual(expected, resultStr);
            }
        }
        public void GetField_FieldContainsDataTestConnectionLimit_StreamIsReturned()
        {
            //Assign
            var templateId = ID.NewID;
            var targetId = ID.NewID;
            var fieldName = "Field";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    {fieldName, ""}
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),

            })
            {
                var fieldValue = "";

                var item = database.GetItem("/sitecore/content/Target");
                var field = item.Fields[fieldName];
                string expected = "hello world";

                var stream = new MemoryStream(Encoding.UTF8.GetBytes(expected));
                var mapper = new SitecoreFieldStreamMapper();

                using (new ItemEditing(item, true))
                {
                    field.SetBlobStream(stream);
                }

                //Act
                var results = new List<Stream>();

                for (int i = 0; i < 1000; i++)
                {
                    var result = mapper.GetField(field, null, null) as Stream;
                    if(result == null)
                        continue;

                    results.Add(result);
                }

                //Assert
                Assert.AreEqual(1000, results.Count);
            }
        }