public void Is_Built_Correctly()
        {
            // Arrange
            const int              testId  = 3;
            var                    testKey = Guid.NewGuid();
            const string           testPropertyEditorAlias = "TestPropertyEditor";
            const ValueStorageType testValueStorageType    = ValueStorageType.Nvarchar;
            const string           testAlias                   = "test";
            const string           testName                    = "Test";
            const int              testSortOrder               = 9;
            const int              testDataTypeId              = 5;
            DateTime               testCreateDate              = DateTime.Now.AddHours(-1);
            DateTime               testUpdateDate              = DateTime.Now;
            const string           testDescription             = "testing";
            const int              testPropertyGroupId         = 11;
            const bool             testMandatory               = true;
            const string           testMandatoryMessage        = "Field is required";
            const string           testValidationRegExp        = "xxxx";
            const string           testValidationRegExpMessage = "Field must match pattern";

            var builder = new PropertyTypeBuilder();

            // Act
            PropertyType propertyType = builder
                                        .WithId(testId)
                                        .WithPropertyEditorAlias(testPropertyEditorAlias)
                                        .WithValueStorageType(testValueStorageType)
                                        .WithAlias(testAlias)
                                        .WithName(testName)
                                        .WithSortOrder(testSortOrder)
                                        .WithDataTypeId(testDataTypeId)
                                        .WithCreateDate(testCreateDate)
                                        .WithUpdateDate(testUpdateDate)
                                        .WithDescription(testDescription)
                                        .WithKey(testKey)
                                        .WithPropertyGroupId(testPropertyGroupId)
                                        .WithMandatory(testMandatory, testMandatoryMessage)
                                        .WithValidationRegExp(testValidationRegExp, testValidationRegExpMessage)
                                        .Build();

            // Assert
            Assert.AreEqual(testId, propertyType.Id);
            Assert.AreEqual(testPropertyEditorAlias, propertyType.PropertyEditorAlias);
            Assert.AreEqual(testValueStorageType, propertyType.ValueStorageType);
            Assert.AreEqual(testAlias, propertyType.Alias);
            Assert.AreEqual(testName, propertyType.Name);
            Assert.AreEqual(testSortOrder, propertyType.SortOrder);
            Assert.AreEqual(testDataTypeId, propertyType.DataTypeId);
            Assert.AreEqual(testCreateDate, propertyType.CreateDate);
            Assert.AreEqual(testUpdateDate, propertyType.UpdateDate);
            Assert.AreEqual(testDescription, propertyType.Description);
            Assert.AreEqual(testKey, propertyType.Key);
            Assert.AreEqual(testPropertyGroupId, propertyType.PropertyGroupId.Value);
            Assert.AreEqual(testMandatory, propertyType.Mandatory);
            Assert.AreEqual(testMandatoryMessage, propertyType.MandatoryMessage);
            Assert.AreEqual(testValidationRegExp, propertyType.ValidationRegExp);
            Assert.AreEqual(testValidationRegExpMessage, propertyType.ValidationRegExpMessage);
        }
Exemplo n.º 2
0
 private PropertyType BuildPropertyType() =>
 _builder
 .WithId(3)
 .WithPropertyEditorAlias("TestPropertyEditor")
 .WithAlias("test")
 .WithName("Test")
 .WithSortOrder(9)
 .WithDataTypeId(5)
 .WithDescription("testing")
 .WithPropertyGroupId(11)
 .WithMandatory(true)
 .WithValidationRegExp("xxxx")
 .Build();