예제 #1
0
        public void TestCanCreateTypedObjectAndPopulatePublicAndPrivateValuesFromValueItems()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            DomainModel model = configSection.Create <DomainModel>(false);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(2, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanCreateTypedObjectAndPopulatePublicValuesFromValueItems()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            DomainModel model = configSection.Create<DomainModel>();

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(5, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanCreateTypedObjectAndPopulateWithFieldMappings()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            IDictionary<string, string> mappings = new Dictionary<string, string>();
            mappings.Add("NoUnits", "NumberUnits");

            DomainModel model = configSection.Create<DomainModel>(false, mappings);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
예제 #4
0
        public void TestCanCreateTypedObjectAndPopulateWithFieldMappings()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("NoUnits", "NumberUnits");

            DomainModel model = configSection.Create <DomainModel>(mappings, true);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanCreateObjectThatDoesntHaveEmptyConstructor()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();
            mappings.Add("NoUnits", "NumberUnits");
            mappings.Add("name", "Name");
            mappings.Add("canExecute", "CanExecute");

            ComplexDomainModel model = configSection.Create<ComplexDomainModel>(mappings, true);

            Assert.AreEqual("model", model.GetResultOfConstructorSetName());
            Assert.IsTrue(model.GetResultOfConstructorSetCanExecute());
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
예제 #6
0
        public void TestCanCreateObjectThatDoesntHaveEmptyConstructor()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("NoUnits", "NumberUnits");
            mappings.Add("name", "Name");
            mappings.Add("canExecute", "CanExecute");

            ComplexDomainModel model = configSection.Create <ComplexDomainModel>(mappings, true);

            Assert.AreEqual("model", model.GetResultOfConstructorSetName());
            Assert.IsTrue(model.GetResultOfConstructorSetCanExecute());
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanCreateObjectWithDefaultValuesUsingObjectCreationSettingsCollection()
        {
            const string description = "This is my Test description";
            const string numberUnitsStr = "4456";
            const int numberUnitsInt = 4456;

            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("MinDefaultedTypedDataConfig").GetSection("model");
            ObjectCreationSettingsCollection settings = configSection.CreateCreationSettingsCollection();
            settings.SetValue("NumberUnits", numberUnitsStr);
            settings.SetValue("Description", description);

            DefaultsDomainModel model = configSection.Create<DefaultsDomainModel>(settings);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual(description, model.Description);
            Assert.AreEqual(numberUnitsInt, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(2, model.MySecretNumber);
        }
예제 #8
0
        public void TestCanCreateObjectWithDefaultValuesUsingObjectCreationSettingsCollection()
        {
            const string description    = "This is my Test description";
            const string numberUnitsStr = "4456";
            const int    numberUnitsInt = 4456;

            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("MinDefaultedTypedDataConfig").GetSection("model");
            ObjectCreationSettingsCollection   settings      = configSection.CreateCreationSettingsCollection();

            settings.SetValue("NumberUnits", numberUnitsStr);
            settings.SetValue("Description", description);

            DefaultsDomainModel model = configSection.Create <DefaultsDomainModel>(settings);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual(description, model.Description);
            Assert.AreEqual(numberUnitsInt, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(2, model.MySecretNumber);
        }
예제 #9
0
        public void TestCanPopulateExistingObjectAndOverrideSomeValues()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            var model = configSection.Create <DomainModel>();

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());

            CustomConfigurations.ConfigSection subConfigSection = new CustomConfigurations.Config("SubTypedDataConfig").GetSection("subModel");
            Assert.IsNotNull(subConfigSection);

            subConfigSection.Populate(model);

            Assert.AreEqual("subModel", model.Name);
            Assert.IsFalse(model.CanExecute);
            Assert.AreEqual("my description", model.Description);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanPopulateExistingObjectAndOverrideSomeValues()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            var model = configSection.Create<DomainModel>();

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());

            CustomConfigurations.ConfigSection subConfigSection = new CustomConfigurations.Config("SubTypedDataConfig").GetSection("subModel");
            Assert.IsNotNull(subConfigSection);

            subConfigSection.Populate(model);

            Assert.AreEqual("subModel", model.Name);
            Assert.IsFalse(model.CanExecute);
            Assert.AreEqual("my description", model.Description);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }