Exemplo n.º 1
0
        public void Triggering_The_AddProperty_Event_Adds_A_New_Property_To_The_Entity()
        {
            IMainPanel  mainPanel = MockRepository.GenerateStub <IMainPanel>();
            IEntityForm form      = MockRepository.GenerateMock <IEntityForm>();

            Entity entity = new EntityImpl("Entity1")
            {
                Key = new EntityKeyImpl()
            };

            entity.AddProperty(new PropertyImpl("Prop1"));

            form.Expect(f => f.SetProperties(Arg <IEnumerable <Property> > .List.ContainsAll(entity.ConcreteProperties)));

            var presenter = new EntityPresenter(mainPanel, form);

            presenter.AttachToModel(entity);

            form.Raise(f => f.AddNewProperty += null, form, new EventArgs());

            Assert.That(entity.Properties.Count(), Is.EqualTo(2));

            form.AssertWasCalled(f => f.Mappings = entity.Mappings(), c => c.Repeat.Twice());
            form.AssertWasCalled(f => f.SetSelectedPropertyName(entity.Properties.ElementAt(1)));
            form.VerifyAllExpectations();
        }
Exemplo n.º 2
0
        public void The_Presenter_Fills_In_The_Form()
        {
            IMainPanel  mainPanel = MockRepository.GenerateStub <IMainPanel>();
            IEntityForm form      = MockRepository.GenerateMock <IEntityForm>();

            form.Expect(f => f.Mappings = null)
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Mapping>)action.Arguments[0]).Count(), Is.EqualTo(0)));
            form.Expect(f => f.SetAvailableTables(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <ITable>)action.Arguments[0]).Count(), Is.EqualTo(0)));

            form.Expect(f => f.SetProperties(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Property>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetAvailableEntities(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Entity>)action.Arguments[0]).Count(), Is.EqualTo(2)));

            form.Expect(f => f.SetChildEntities(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            Entity    parentEntity = new EntityImpl("Parent");
            Entity    childEntity  = new EntityImpl("Child");
            Property  property     = new PropertyImpl("Prop1");
            EntityKey key          = new EntityKeyImpl();
            Entity    entity       = new EntityImpl("Entity1")
            {
                Key = key
            };

            entity.Parent = parentEntity;
            entity.AddChild(childEntity);
            entity.AddProperty(property);
            key.AddProperty(property);

            EntitySet es = new EntitySetImpl();

            es.AddEntity(parentEntity);
            es.AddEntity(entity);
            es.AddEntity(childEntity);
            MappingSet ms = new MappingSetImpl();

            ms.EntitySet = es;

            var presenter = new EntityPresenter(mainPanel, form);

            presenter.AttachToModel(entity);

            form.AssertWasCalled(f => f.EntityName    = entity.Name);
            form.AssertWasCalled(f => f.Discriminator = entity.Discriminator);
            form.AssertWasCalled(f => f.ParentEntity  = entity.Parent);
            form.AssertWasCalled(f => f.SetVirtualProperties(entity.Ex));
            form.VerifyAllExpectations();
        }
Exemplo n.º 3
0
        public void Clear_Called()
        {
            IEntityForm form = MockRepository.GenerateMock <IEntityForm>();
            Entity      obj  = MockRepository.GenerateStub <Entity>();

            obj.Key = new EntityKeyImpl();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            var presenter = new EntityPresenter(panel, form);

            presenter.AttachToModel(obj);

            form.AssertWasCalled(f => f.Clear());
        }
Exemplo n.º 4
0
        public void The_Presenter_Hooks_Up_To_The_Right_Events_On_The_Form()
        {
            IMainPanel  mainPanel = MockRepository.GenerateStub <IMainPanel>();
            IEntityForm form      = MockRepository.GenerateMock <IEntityForm>();

            new EntityPresenter(mainPanel, form);

            form.AssertWasCalled(f => f.NameChanged              += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.AddNewProperty           += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.PropertyNameChanged      += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.CreateNewTableFromEntity += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.RemoveEntity             += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.RemoveProperty           += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.EditProperty             += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.MappingsChanged          += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.NewMappingAdded          += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.CopyProperty             += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.MappingRemoved           += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.SingleMappingChanged     += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.DiscriminatorChanged     += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.ParentEntityChanged      += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.ChildEntityAdded         += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.ChildEntityRemoved       += null, c => c.IgnoreArguments());
        }