public void SelectSchemaType_ShouldSelectItsRelatedTypes()
        {
            using (var objectSelection = new SchemaTypesViewModel
            {
                SchemaTypes = new List <SchemaTypeModel>
                {
                    new SchemaTypeModel {
                        Name = "Type1", IsSelected = false
                    },
                    new SchemaTypeModel {
                        Name = "Type2", IsSelected = true
                    },
                    new SchemaTypeModel {
                        Name = "Type3", IsSelected = false
                    }
                }
            })
            {
                var relatedEntityType = new EdmEntityType("Test", "RelatedEntityType");
                var listToLoad        = new List <IEdmSchemaType>
                {
                    relatedEntityType,
                    new EdmComplexType("Test", "ComplexType", new EdmComplexType("Test", "BaseComplexType")),
                    new EdmEntityType("Test", "EntityType", relatedEntityType)
                };

                objectSelection.LoadSchemaTypes(listToLoad, new Dictionary <IEdmType, List <IEdmOperation> >());
                objectSelection.DeselectAllSchemaTypes();

                objectSelection.SchemaTypes.First(x => x.ShortName == "EntityType").IsSelected = true;

                objectSelection.SchemaTypes.ShouldBeEquivalentTo(new List <SchemaTypeModel>
                {
                    new SchemaTypeModel {
                        ShortName = "ComplexType", Name = "Test.ComplexType", IsSelected = false
                    },
                    new SchemaTypeModel {
                        ShortName = "EntityType", Name = "Test.EntityType", IsSelected = true
                    },
                    new SchemaTypeModel {
                        ShortName = "RelatedEntityType", Name = "Test.RelatedEntityType", IsSelected = true
                    }
                });
            }
        }
        public void SelectBoundOperation_ShouldSelectItsRequiredType()
        {
            using (var objectSelection = new SchemaTypesViewModel
            {
                SchemaTypes = new List <SchemaTypeModel>
                {
                    new SchemaTypeModel {
                        Name = "Type1", IsSelected = false
                    },
                    new SchemaTypeModel {
                        Name = "Type2", IsSelected = true
                    },
                    new SchemaTypeModel {
                        Name = "Type3", IsSelected = false
                    }
                }
            })
            {
                var relatedEntityType = new EdmEntityType("Test", "RelatedEntityType");
                var listToLoad        = new List <IEdmSchemaType>
                {
                    relatedEntityType,
                    new EdmComplexType("Test", "ComplexType", new EdmComplexType("Test", "BaseComplexType")),
                    new EdmEntityType("Test", "EntityType", relatedEntityType)
                };

                var boundOperation = new EdmAction("Test", "BoundOperation",
                                                   new EdmPrimitiveTypeReference(new EdmPrimitiveType(EdmPrimitiveTypeKind.Boolean), false), true,
                                                   new EdmPathExpression(string.Empty));
                boundOperation.AddParameter("relatedEntityTypeParameter",
                                            new EdmEntityTypeReference(relatedEntityType, false));

                objectSelection.LoadSchemaTypes(listToLoad, new Dictionary <IEdmType, List <IEdmOperation> >
                {
                    {
                        relatedEntityType, new List <IEdmOperation>
                        {
                            boundOperation
                        }
                    }
                });
                objectSelection.DeselectAllSchemaTypes();

                objectSelection.SchemaTypes.FirstOrDefault(x => x.ShortName == "RelatedEntityType")?.IsSelected.Should()
                .BeFalse();
                objectSelection.SchemaTypes.First(x => x.ShortName == "RelatedEntityType").BoundOperations
                .First().IsSelected = true;
                objectSelection.SchemaTypes.FirstOrDefault(x => x.ShortName == "RelatedEntityType")?.IsSelected.Should()
                .BeTrue();

                objectSelection.SchemaTypes.ShouldBeEquivalentTo(new List <SchemaTypeModel>
                {
                    new SchemaTypeModel
                    {
                        ShortName       = "ComplexType", Name = "Test.ComplexType", IsSelected = false,
                        BoundOperations = new List <BoundOperationModel>()
                    },
                    new SchemaTypeModel
                    {
                        ShortName       = "EntityType", Name = "Test.EntityType", IsSelected = false,
                        BoundOperations = new List <BoundOperationModel>()
                    },
                    new SchemaTypeModel
                    {
                        ShortName       = "RelatedEntityType", Name = "Test.RelatedEntityType", IsSelected = true,
                        BoundOperations = new List <BoundOperationModel>
                        {
                            new BoundOperationModel
                            {
                                Name       = "BoundOperation(Test.RelatedEntityType)",
                                ShortName  = "BoundOperation",
                                IsSelected = true
                            }
                        }
                    }
                });
            }
        }