public void GetPropertiesReturnsAmplaField()
        {
            ModelProperties <ModelWithAmplaField> modelProperties = new ModelProperties <ModelWithAmplaField>();

            var properties = modelProperties.GetProperties();

            Assert.That(properties.Count, Is.EqualTo(1));
            Assert.That(properties[0], Is.EqualTo("Full Name"));
        }
        public void GetPropertiesReturnsAmplaField()
        {
            ModelProperties <ModelWithTimeSpanField> modelProperties = new ModelProperties <ModelWithTimeSpanField>();

            var properties = modelProperties.GetProperties();

            Assert.That(properties.Count, Is.EqualTo(1));
            Assert.That(properties[0], Is.EqualTo("Duration"));
        }
        public void TestInheritedModel()
        {
            ModelProperties <InheritedModel> modelProperties = new ModelProperties <InheritedModel>();

            Assert.That(modelProperties.GetLocation(null), Is.EqualTo("Enterprise.Site.Area.Simple"));
            Assert.That(modelProperties.Module, Is.EqualTo(AmplaModules.Production));

            IList <string> properties = modelProperties.GetProperties();

            Assert.That(properties, Contains.Item("Id").And.Contains("Name").And.Contains("Value"));
            Assert.That(properties.Count, Is.EqualTo(3));
        }
        public void TestReadOnlyProperties()
        {
            ModelWithReadOnly model = new ModelWithReadOnly();

            ModelProperties <ModelWithReadOnly> modelProperties = new ModelProperties <ModelWithReadOnly>();

            Assert.That(modelProperties.GetProperties().Count, Is.EqualTo(4));

            model.Name = "name1";
            AssertPropertyGetValue(modelProperties, model, "ReadOnlyName", "name1");
            AssertPropertyNotSetValue(modelProperties, model, "ReadOnlyName", "invalid name");
        }
Example #5
0
        public void GetPropertiesReturnsLocationField()
        {
            ModelProperties <ModelWithLocationField> modelProperties = new ModelProperties <ModelWithLocationField>();
            ModelWithLocationField model = new ModelWithLocationField();

            var properties = modelProperties.GetProperties();

            Assert.That(properties.Count, Is.EqualTo(1));
            Assert.That(properties[0], Is.EqualTo("Location"));

            Assert.That(modelProperties.IsDefaultValue(model, "Location"), Is.True);

            model.Location = "Enterprise.Site";
            Assert.That(modelProperties.IsDefaultValue(model, "Location"), Is.False);
        }
        public void TestWriteOnlyProperties()
        {
            ModelWithWriteOnly model = new ModelWithWriteOnly();

            ModelProperties <ModelWithWriteOnly> modelProperties = new ModelProperties <ModelWithWriteOnly>();

            Assert.That(modelProperties.GetProperties().Count, Is.EqualTo(4));

            AssertPropertySetValue(modelProperties, model, "Id", "100");
            AssertPropertySetValue(modelProperties, model, "Name", "old name");
            AssertPropertySetValue(modelProperties, model, "Value", "123.4");

            Assert.That(model.Id, Is.EqualTo(100));
            Assert.That(model.Name, Is.EqualTo("old name"));
            Assert.That(model.Value, Is.EqualTo(123.4));

            AssertPropertySetValue(modelProperties, model, "WriteOnlyName", "new name");
            Assert.That(model.Name, Is.EqualTo("new name"));

            AssertPropertyNotGetValue(modelProperties, model, "WriteOnlyName");
        }