コード例 #1
0
        public async void OrganizationTypeER_GetNewObject()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            Assert.NotNull(organizationType);
            Assert.False(organizationType.IsValid);
        }
コード例 #2
0
        public async Task OrganizationTypeER_TestInvalidSave()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            organizationType.Name = String.Empty;

            Assert.False(organizationType.IsValid);
            Assert.Throws <Csla.Rules.ValidationException>(() => organizationType.Save());
        }
コード例 #3
0
        public async Task OrganizationTypeER_NameRequired()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            organizationType.Name = "valid name";
            organizationType.CategoryOfOrganization = await CategoryOfOrganizationEC.NewCategoryOfOrganizationEC();

            organizationType.CategoryOfOrganization.Category = "category name";
            var isObjectValidInit = organizationType.IsValid;

            organizationType.Name = String.Empty;

            Assert.NotNull(organizationType);
            Assert.True(isObjectValidInit);
            Assert.False(organizationType.IsValid);
        }
コード例 #4
0
        public async Task OrganizationTypeER_InsertNewObjectIntoDatabase()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            organizationType.Name = "inserted name";
            organizationType.CategoryOfOrganization = await CategoryOfOrganizationEC.GetCategoryOfOrganizationEC(
                new CategoryOfOrganization
            {
                Id           = 1,
                Category     = "Category name",
                DisplayOrder = 1
            });

            var savedOrganizationType = await organizationType.SaveAsync();

            Assert.NotNull(savedOrganizationType);
            Assert.IsType <OrganizationTypeER>(savedOrganizationType);
            Assert.True(savedOrganizationType.Id > 0);
        }
コード例 #5
0
        public async Task OrganizationTypeER_NameExceedsMaxLengthOf50()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            organizationType.Name = "valid name";
            organizationType.CategoryOfOrganization = await CategoryOfOrganizationEC.NewCategoryOfOrganizationEC();

            organizationType.CategoryOfOrganization.Category = "category name";
            var isValidOrig = organizationType.IsValid;

            organizationType.Name =
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
                "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis ";

            Assert.NotNull(organizationType);
            Assert.True(isValidOrig);
            Assert.False(organizationType.IsValid);
            Assert.Equal("Name", organizationType.BrokenRulesCollection[0].Property);

            Assert.Equal("Name can not exceed 50 characters",
                         organizationType.BrokenRulesCollection[0].Description);
        }