public async void OrganizationTypeER_GetNewObject()
        {
            var organizationType = await OrganizationTypeER.NewOrganizationTypeER();

            Assert.NotNull(organizationType);
            Assert.False(organizationType.IsValid);
        }
        public async void OrganizationTypeER_Get()
        {
            var organizationType = await OrganizationTypeER.GetOrganizationTypeER(1);

            Assert.NotNull(organizationType);
            Assert.Equal(1, organizationType.Id);
            Assert.True(organizationType.IsValid);
        }
        public async Task OrganizationTypeER_DeleteObjectFromDatabase()
        {
            const int ID_TO_DELETE = 99;

            await OrganizationTypeER.DeleteOrganizationTypeER(ID_TO_DELETE);

            var categoryToCheck = await Assert.ThrowsAsync <Csla.DataPortalException>
                                      (() => OrganizationTypeER.GetOrganizationTypeER(ID_TO_DELETE));
        }
        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());
        }
        public async void OrganizationTypeER_UpdateExistingObjectInDatabase()
        {
            var updatedName      = "new name";
            var organizationType = await OrganizationTypeER.GetOrganizationTypeER(1);

            organizationType.Name = updatedName;

            var result = await organizationType.SaveAsync();

            Assert.NotNull(result);
            Assert.Equal(updatedName, result.Name);
        }
        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);
        }
        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);
        }
        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);
        }