private void setupStandardizedFixture()
        {
            //all core dependencies use mock objects
            //StandardizedFixture = new Fixture();
            StandardizedFixture.Inject(MockPosition);
            StandardizedFixture.Inject(MockKeybindGenerator);
            StandardizedFixture.Inject(MockDesktopCharacterTargeter);
            StandardizedFixture.Inject(MockMemoryInstance);
            StandardizedFixture.Inject(MockCamera);
            StandardizedFixture.Inject(MockCharacterProgressBarStats);
            StandardizedFixture.Inject(MockActionGroup);

            //map interfaces to classes
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(DesktopCharacterTargeter),
                    typeof(DesktopCharacterTargeterImpl)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(DesktopCharacterTargeter),
                    typeof(DesktopCharacterTargeterImpl)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(DesktopMemoryCharacter),
                    typeof(DesktopMemoryCharacterImpl)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(ManagedCharacter),
                    typeof(ManagedCharacterImpl)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(CharacterActionList <Identity>),
                    typeof(CharacterActionListImpl <Identity>)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(Identity),
                    typeof(IdentityImpl)));
            StandardizedFixture.Customizations.Add(
                new TypeRelay(
                    typeof(CharacterActionContainer),
                    typeof(ManagedCharacterImpl)));

            StandardizedFixture.Customize <IdentityImpl>(i => i
                                                         .Without(x => x.AnimationOnLoad));
            StandardizedFixture.Customize <ManagedCharacterImpl>(i => i
                                                                 .Without(x => x.GhostShadow));
            //handle recursion
            StandardizedFixture.Behaviors.Add(new OmitOnRecursionBehavior());
        }
Exemple #2
0
        private void setupFixtureToBuildCrowdRepositories()
        {
            //setup repository with dependencies that have cicruclar ref back to repo removed
            StandardizedFixture.Customize <CrowdRepositoryImpl>(c => c
                                                                .Without(x => x.NewCrowdInstance)
                                                                .Without(x => x.NewCharacterCrowdMemberInstance)
                                                                .Without(x => x.Crowds)
                                                                .With(x => x.UsingDependencyInjection, false)
                                                                );

            StandardizedFixture.Customize <CrowdImpl>(c => c
                                                      .Without(x => x.AllCrowdMembershipParents)
                                                      .Without(x => x.MemberShips)
                                                      //.With(x => x.Members, new ObservableCollection<HeroVirtualTabletop.Crowd.CrowdMember>())
                                                      .Without(x => x.Members)
                                                      );

            StandardizedFixture.Customize <CharacterCrowdMemberImpl>(c => c
                                                                     .Without(x => x.AllCrowdMembershipParents)
                                                                     .Without(x => x.DesktopNavigator)
                                                                     .Without(x => x.CharacterActionGroups)
                                                                     );

            var crowds = StandardizedFixture.CreateMany <Crowd>().ToList();

            //now setup repo again with dependencies included.
            //the dependencies are now referring to a parent repo
            //with no refefrence to these dependencies so circular ref is broken
            StandardizedFixture.Customize <CrowdRepositoryImpl>(c => c
                                                                .With(x => x.NewCrowdInstance, StandardizedFixture.Create <Crowd>())
                                                                .With(x => x.NewCharacterCrowdMemberInstance, StandardizedFixture.Create <CharacterCrowdMember>())
                                                                //also add the crowds previously created
                                                                .Do(x => crowds.ForEach(t => x.Crowds.Add(t)))
                                                                );

            //create a repo based on above config ie the dependencies with circular ref removed
            var repo = StandardizedFixture.Create <CrowdRepositoryImpl>();

            //add the the circular ref back to the repo to the dependencies
            //AUTOFIXTURE AND CIRC DEPENDECIES SUCK!!!
            repo.NewCrowdInstance.CrowdRepository = repo;
            repo.NewCharacterCrowdMemberInstance.CrowdRepository = repo;

            StandardizedFixture.Inject <CrowdRepository>(repo);
        }