Exemplo n.º 1
0
        public void Setup()
        {
            var behavior = new TestBehavior(ValueStage.Value);

            VM      = ViewModelStub.WithBehaviors(behavior).Build();
            Manager = behavior.Manager;
            Context = new BehaviorContextStub(VM);
        }
        public void Setup()
        {
            Behavior = new ItemProviderBehavior <TestSourceObject, TestSourceItem>();

            Context = ViewModelStub
                      .WithBehaviors(Behavior)
                      .BuildContext();
        }
        protected static ViewModelStub CreateInvalidVM(ValidationResult validationResult)
        {
            var behavior = new ValidationResultAggregatorStub();

            behavior.ReturnedValidationResults[ValidationResultScope.All] = validationResult;

            return(ViewModelStub
                   .WithBehaviors(behavior)
                   .Build());
        }
        public void Setup()
        {
            ActionLogBuilder = new StringBuilder();
            Behavior         = new ViewModelValidationSourceBehavior();
            Next             = new NextBehavior(ActionLogBuilder);
            Executor         = new TestExecutor(ActionLogBuilder);

            VM = ViewModelStub
                 .WithBehaviors(Behavior, Next, Executor)
                 .Build();

            Context = VM.GetContext();
        }
Exemplo n.º 5
0
        public void Setup()
        {
            Next = new ValidationResultAggregatorStub();
            Next.ReturnedValidationResults[ValidationResultScope.PropertiesOnly]           = PropertyResult;
            Next.ReturnedValidationResults[ValidationResultScope.ViewModelValidationsOnly] = ViewModelResult;
            Next.ReturnedValidationResults[ValidationResultScope.Descendants] = DescendantResult;

            Behavior = new ValidationResultAggregatorCacheBehavior();

            Counter = new NextAggregatorInvocationCounter();

            Context = ViewModelStub
                      .WithBehaviors(Behavior, Counter, Next)
                      .BuildContext();
        }
Exemplo n.º 6
0
        public void HandleChange_AlsoRefreshesParentCaches()
        {
            Behavior.GetValidationResult(Context, ValidationResultScope.All);
            var newResult = ChangeNextResultsAndReturnJoinedResults();

            var childBehavior = new ValidationResultAggregatorCacheBehavior();
            var childVM       = ViewModelStub
                                .WithBehaviors(childBehavior, new ValidationResultAggregatorStub())
                                .Build();

            childVM.Kernel.Parents.Add(Context.VM);

            childBehavior.HandleChange(
                childVM.GetContext(),
                ChangeArgs.ValidationResultChanged().PrependViewModel(ViewModelStub.Build())
                );

            var actualResult = Behavior.GetValidationResult(Context, ValidationResultScope.All);

            Assert.AreEqual(newResult, actualResult);
        }
Exemplo n.º 7
0
            public ItemInCollectionSetup(StringBuilder log)
            {
                ItemExecutor            = new ValidationExecutorStub();
                CollectionOwnerExecutor = new ValidationExecutorStub();

                ItemProperty = PropertyStub
                               .WithBehaviors(new RevalidationBehaviorSpy(log))
                               .Build();

                Item = ViewModelStub
                       .WithBehaviors(ItemExecutor, new RevalidationBehaviorSpy(log))
                       .WithProperties(ItemProperty)
                       .Build();

                var collectionOwner = ViewModelStub
                                      .WithBehaviors(CollectionOwnerExecutor)
                                      .Build();

                Collection = VMCollectionStub
                             .WithItems(Item)
                             .WithOwner(collectionOwner)
                             .Build();
            }