상속: Attribute
예제 #1
0
        public void Can_Combine_All_Operations()
        {
            //Arrange
            var builder = new ModifyRequestBuilder();

            //Act
            builder.Context("/foo/bar")
            .ReturnNoAttributes()
            .FailOnError()
            .AddModification(Modifications.RemoveAttribute, SimpleAttribute.New(AttributeTypes.Integer, "objectId"))
            .AddModifications(() => new List <ModificationItem> {
                ModificationItem.New(
                    Modifications.AdvanceState, StructureAttribute.New(390, new StructureValue(10))
                    ),
                ModificationItem.New(
                    Modifications.RegressState, StructureAttribute.New(24, new StructureValue(10))
                    )
            })
            .ConfigureLookupControls()
            .ReturnAttributes(390, 24)
            .ReturnLanguages(10);

            var request = new BatchRequest(builder.Build());

            Console.WriteLine(builder.Build().ToAdsml().ToString());

            //Assert
            Assert.DoesNotThrow(() => builder.Build());
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void Can_Instantiate_New_SimpleAttribute_With_FactoryMethod()
        {
            //Act
            var attribute = SimpleAttribute.New(AttributeTypes.Integer, "objectId", "1777");

            //Assert
            Assert.That(attribute, Is.Not.Null);
        }
        public void Can_Instantiate_New_SimpleAttribute()
        {
            //Act
            var attribute = new SimpleAttribute(AttributeTypes.Text);

            //Assert
            Assert.That(attribute, Is.Not.Null);
        }
예제 #4
0
        public void Can_Instantiate_New_ModificationItem_With_FactoryMethod()
        {
            //Act
            var modItem = ModificationItem.New(Modifications.RemoveValue,
                                               SimpleAttribute.New(AttributeTypes.Text, "foo"));

            //Assert
            Assert.That(modItem, Is.Not.Null);
        }
        public void Instantiation_Sets_Correct_Values_On_BaseType_Props()
        {
            //Act
            var attribute = new SimpleAttribute(AttributeTypes.Date);

            //Assert
            Assert.That(attribute.AttributeType, Is.EqualTo(AttributeTypes.Date));
            Assert.That(attribute.ElementName, Is.EqualTo("SimpleAttribute"));
        }
예제 #6
0
        /// <summary>
        /// Base method for retrieving Data extension element values.
        /// </summary>
        /// <param name="extension">The name of the Data extension element to look for</param>
        /// <returns>value as string, or NULL if the extension was not found</returns>
        public string getAccountExtensionValue(string extension)
        {
            SimpleAttribute e = getDataExtension(extension);

            if (e != null)
            {
                return((string)e.Value);
            }
            return(null);
        }
        public string getWebmasterToolsAttributeValue(string extension)
        {
            SimpleAttribute e = getWebmasterToolsAttribute(extension);

            if (e != null)
            {
                return((string)e.Value);
            }
            return(null);
        }
예제 #8
0
        public string getWebmasterToolsAttributeValue(string extension)
        {
            SimpleAttribute attribute = this.getWebmasterToolsAttribute(extension);

            if (attribute != null)
            {
                return(attribute.Value);
            }
            return(null);
        }
예제 #9
0
        /// <summary>
        /// Base method for retrieving Calendar extension element values.
        /// </summary>
        /// <param name="extension">The name of the Calendar extension element to look for</param>
        /// <returns>value as string, or NULL if the extension was not found</returns>
        public string getCalendarExtensionValue(string extension)
        {
            SimpleAttribute e = getCalendarExtension(extension);

            if (e != null)
            {
                return((string)e.Value);
            }
            return(null);
        }
예제 #10
0
        public void Can_Add_ModificationItem()
        {
            //Arrange
            var builder = new ModifyRequestBuilder();

            //Act
            builder.AddModification(Modifications.RemoveValue, SimpleAttribute.New(AttributeTypes.Integer, "objectId"));

            //Assert
            Assert.That(builder.Modifications.Count(), Is.EqualTo(1));
        }
        public void GetAttributes_Inherit_Method()
        {
            // Arrange
            var provider = typeof(ChildPoco).GetMethod(nameof(ChildPoco.MyMethod));
            var expected = new SimpleAttribute[] { new ChildAttribute() };

            // Act
            var actual = CustomAttributeProviderExtensions.GetAttributes <SimpleAttribute>(provider);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
예제 #12
0
        public void GetEnumValueAttribute()
        {
            // Arrange
            var expected = new SimpleAttribute {
                MyInt = 1, MyString = "a"
            };

            // Act
            var actual = EnumAttributeHelper.GetEnumValueAttribute <SimpleAttribute>(TestEnum.Value0);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
        public void Validate_Throws_ASVE_If_Name_Is_Not_Set()
        {
            //Arrange
            var attribute = new SimpleAttribute(AttributeTypes.Binary)
            {
                Values = new List <string> {
                    "1777"
                }
            };

            //Act
            attribute.ToAdsml();
        }
예제 #14
0
        public SimpleElement setWebmasterToolsAttribute(string extension, string newValue)
        {
            if (extension == null)
            {
                throw new ArgumentNullException("extension");
            }
            SimpleAttribute attribute = this.getWebmasterToolsAttribute(extension);

            if (attribute == null)
            {
                attribute = base.CreateExtension(extension, "http://schemas.google.com/webmasters/tools/2007") as SimpleAttribute;
                base.ExtensionElements.Add(attribute);
            }
            attribute.Value = newValue;
            return(attribute);
        }
        public void CanSetAttributesToBeCreatedWithListFactoryOverload()
        {
            //Arrange
            var builder = new CreateRequestBuilder();

            //Act
            builder.AttributesToSet(
                () => new List <IAdsmlAttribute> {
                StructureAttribute.New(10, new StructureValue(10, "foo")),
                SimpleAttribute.New(AttributeTypes.Text, "objectName", "foo")
            }
                );

            //Assert
            Assert.That(builder.Attributes.Count(), Is.EqualTo(2));
        }
예제 #16
0
        public void Can_Build_ModifyRequest()
        {
            //Arrange
            var builder = new ModifyRequestBuilder();

            //Act
            builder.Context("/foo/bar")
            .AddModification(Modifications.RemoveAttribute, SimpleAttribute.New(AttributeTypes.Integer, "objectId"));

            var request      = builder.Build();
            var batchRequest = new BatchRequest(request);

            //Assert
            Assert.That(request, Is.Not.Null);
            Assert.That(request, Is.InstanceOf <ModifyRequest>());

            Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void Can_Generate_Api_Xml_With_Multiple_Values()
        {
            //Arrange
            var expected = new XElement("SimpleAttribute",
                                        new XAttribute("name", "objectTypeId"),
                                        new XAttribute("type", "integer"),
                                        new XElement("Value", new XCData("12")),
                                        new XElement("Value", new XCData("24"))).ToString();

            var attribute = SimpleAttribute.New(AttributeTypes.Integer, "objectTypeId", new[] { "12", "24" });

            //Act
            var actual = attribute.ToAdsml().ToString();

            Console.WriteLine(actual);

            //Assert
            Assert.That(actual, Is.EqualTo(expected));
        }
        public SimpleElement setWebmasterToolsAttribute(string extension, string newValue)
        {
            if (extension == null)
            {
                throw new System.ArgumentNullException("extension");
            }

            SimpleAttribute ele = getWebmasterToolsAttribute(extension);

            if (ele == null)
            {
                ele = CreateExtension(extension, WebmasterToolsNameTable.gWebmasterToolsNamspace) as SimpleAttribute;
                this.ExtensionElements.Add(ele);
            }

            ele.Value = newValue;

            return(ele);
        }
예제 #19
0
        /// <summary>
        /// Base method for setting Calendar extension element values.
        /// </summary>
        /// <param name="extension">the name of the extension to look for</param>
        /// <param name="newValue">the new value for this extension element</param>
        /// <returns>SimpleAttribute, either a brand new one, or the one
        /// returned by the service</returns>
        public SimpleElement setCalendarExtension(string extension, string newValue)
        {
            if (extension == null)
            {
                throw new System.ArgumentNullException("extension");
            }

            SimpleAttribute ele = getCalendarExtension(extension);

            if (ele == null)
            {
                ele = CreateExtension(extension, GDataParserNameTable.NSGCal) as SimpleAttribute;
                this.ExtensionElements.Add(ele);
            }

            ele.Value = newValue;

            return(ele);
        }
예제 #20
0
        public void Can_Add_ModificationItems_With_ListFactory()
        {
            //Arrange
            var builder = new ModifyRequestBuilder();

            //Act
            builder.AddModifications(() => new List <ModificationItem> {
                ModificationItem.New(
                    Modifications.ReplaceAttribute,
                    SimpleAttribute.New(AttributeTypes.Integer, "foo", "bar")
                    ),
                ModificationItem.New(
                    Modifications.AddAttribute,
                    RelationAttribute.New("foo", "bar")
                    )
            });

            //Assert
            Assert.That(builder.Modifications.Count(), Is.EqualTo(2));
        }
        public void Can_Generate_Api_Xml_Without_Value()
        {
            //Arrange
            var expected = new XElement("SimpleAttribute",
                                        new XAttribute("name", "objectTypeId"),
                                        new XAttribute("type", "integer")).ToString();

            var attribute = new SimpleAttribute(AttributeTypes.Integer)
            {
                Name = "objectTypeId"
            };

            //Act
            var actual = attribute.ToAdsml().ToString();

            Console.WriteLine(actual);

            //Assert
            Assert.That(actual, Is.EqualTo(expected));
        }
예제 #22
0
        public static IAttributeChain Create(string attributeString)
        {
            if (string.IsNullOrEmpty(attributeString))
            {
                throw new QuerySystemException(ErrorCodes.Query.ATTRIBUTE_NULL_OR_EMPTY);
            }
            var             attributor        = new SimpleAttribute();
            var             queue             = new Queue <string>(attributeString.Split('.'));
            SimpleAttribute currentAttributor = attributor;

            while (queue.Count > 0)
            {
                string attribute = queue.Dequeue();
                var    split     = attribute.Split('[');
                if (split.Length > 1)
                {
                    currentAttributor.Name    = split[0];
                    currentAttributor.Indices = new int[split.Length];
                    for (int i = 1; i < split.Length; i++)
                    {
                        var isolate = split[i].Split(']');
                        int index;
                        if (isolate.Length < 2 || !int.TryParse(isolate[0], out index))
                        {
                            throw new QuerySystemException(ErrorCodes.Query.INVALID_ATTRIBUTE);
                        }
                        currentAttributor.Indices[i] = index;
                    }
                }
                else
                {
                    currentAttributor.Name = attribute;
                }
                if (queue.Count > 0)
                {
                    currentAttributor.Child = new SimpleAttribute();
                    currentAttributor       = currentAttributor.Child as SimpleAttribute;
                }
            }
            return(attributor);
        }
예제 #23
0
        public void Can_Build_ModifyRequest_With_Request_Filters()
        {
            //Arrange
            var builder = new ModifyRequestBuilder();

            //Act
            builder.Context("/foo/bar")
            .ReturnNoAttributes()
            .FailOnError()
            .AddModification(Modifications.RemoveAttribute, SimpleAttribute.New(AttributeTypes.Integer, "objectId"));

            var request      = builder.Build();
            var batchRequest = new BatchRequest(request);

            //Assert
            Assert.That(request.RequestFilters.Count(), Is.EqualTo(2));
            Assert.That(request.RequestFilters.ElementAt(0), Is.InstanceOf <ReturnNoAttributesFilter>());
            Assert.That(request.RequestFilters.ElementAt(1), Is.InstanceOf <FailOnErrorFilter>());

            Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
예제 #24
0
        public void Can_Deserialize_SimpleAttribute()
        {
            //Arrange
            var xml =
                new XElement("SimpleAttribute",
                             new XAttribute("name", "name"),
                             new XAttribute("type", "text"),
                             new XElement("Value", "foo"));

            var expected = SimpleAttribute.New(AttributeTypes.Text, "name", "foo");

            var sad = new SimpleAttributeDeserializer();

            //Act
            var actual = (SimpleAttribute)sad.Deserialize(xml);

            //Assert
            Assert.That(actual, Is.InstanceOf <SimpleAttribute>());

            Assert.That(actual.Name, Is.EqualTo(expected.Name));
            Assert.That(actual.AttributeType, Is.EqualTo(expected.AttributeType));

            Assert.That(actual.Values.ElementAt(0), Is.EqualTo(expected.Values.ElementAt(0)));
        }
예제 #25
0
 public void TestSimpleFill()
 {
     var simpleAttribute = new SimpleAttribute();
       this.parser.Fill(simpleAttribute);
       Assert.Equal<string>(simpleAttribute.Name, "John Doe");
 }