예제 #1
0
    public void SetPropertyValue_InvalidProperty_ReturnsFalse() {

      var types                 = new TypeMemberInfoCollection();
      var topic                 = TopicFactory.Create("Test", "ContentType");

      var isInvalidPropertySet  = types.SetPropertyValue(topic, "InvalidProperty", "Invalid");

      Assert.IsFalse(isInvalidPropertySet);

    }
예제 #2
0
    public void SetPropertyValue_Boolean_SetsValue() {

      var types                 = new TypeMemberInfoCollection();
      var topic                 = TopicFactory.Create("Test", "ContentType");

      types.SetPropertyValue(topic, "IsHidden", "1");

      Assert.IsTrue(topic.IsHidden);

    }
예제 #3
0
    public void SetPropertyValue_DateTime_SetsValue() {

      var types                 = new TypeMemberInfoCollection();
      var topic                 = TopicFactory.Create("Test", "ContentType");

      var isDateSet             = types.SetPropertyValue(topic, "LastModified", "June 3, 2008");
          isDateSet             = types.SetPropertyValue(topic, "LastModified", "2008-06-03") && isDateSet;
          isDateSet             = types.SetPropertyValue(topic, "LastModified", "06/03/2008") && isDateSet;

      var lastModified          = DateTime.Parse(
        types.GetPropertyValue(topic, "LastModified", typeof(DateTime)).ToString(),
        CultureInfo.InvariantCulture
      );

      Assert.IsTrue(isDateSet);
      Assert.AreEqual<DateTime>(new(2008, 6, 3), topic.LastModified);
      Assert.AreEqual<DateTime>(new(2008, 6, 3), lastModified);

    }
예제 #4
0
    public void SetPropertyValue_ReflectionPerformance() {

      var totalIterations = 1;
      var types = new TypeMemberInfoCollection();
      var topic = TopicFactory.Create("Test", "ContentType");

      int i;
      for (i = 0; i < totalIterations; i++) {
        types.SetPropertyValue(topic, "Key", "Key" + i);
      }

      Assert.AreEqual<string>("Key" + (i-1), topic.Key);

    }
예제 #5
0
    public void SetPropertyValue_Key_SetsValue() {

      var types                 = new TypeMemberInfoCollection();
      var topic                 = TopicFactory.Create("Test", "ContentType");

      var isKeySet              = types.SetPropertyValue(topic, "Key", "NewKey");

      var key                   = types.GetPropertyValue(topic, "Key", typeof(string)).ToString();

      Assert.IsTrue(isKeySet);
      Assert.AreEqual<string>("NewKey", topic.Key);
      Assert.AreEqual<string>("NewKey", key);

    }