private void GetSelectableClasses(ClassRowCM[] classRowCMs)
        {
            //Pull class data from DB, map it to a set of Class list models.
            List <PlayableClass> PCs = _userAccess.GetAllPlayableClasses().ToList();
            ReadModelMapper <PlayableClass, ClassesListModel> mapper = new ReadModelMapper <PlayableClass, ClassesListModel>();
            List <ClassesListModel> playableList = new List <ClassesListModel>();

            foreach (PlayableClass pc in PCs)
            {
                ClassesListModel lm = mapper.mapDataModelToViewModel(pc);
                playableList.Add(lm);
            }

            //add copies of that set of list models to each CM.
            foreach (ClassRowCM rowCM in classRowCMs)
            {
                rowCM.playableClasses = playableList.ToArray();

                if (rowCM.SelectedClass_id != null)
                {
                    //get that CM's subclasses, turn it into a set of Subclasses List Models, and set.
                    List <Subclass> foundSubclasses = _userAccess.GetAllSubclassesForClass(rowCM.SelectedClass_id).ToList();
                    ReadModelMapper <Subclass, SubclassesListModel> subclassMapper = new ReadModelMapper <Subclass, SubclassesListModel>();
                    List <SubclassesListModel> subclasses = new List <SubclassesListModel>();
                    foreach (Subclass sc in foundSubclasses)
                    {
                        SubclassesListModel lm = subclassMapper.mapDataModelToViewModel(sc);
                        subclasses.Add(lm);
                    }
                    rowCM.subclasses = subclasses.ToArray();
                }
            }
        }
예제 #2
0
        public void CMBuilder_buildNewClassRowCM()
        {
            //Arrange
            List <PlayableClass>    playableClasses = CreateTestData.GetPlayableClasses();
            List <ClassesListModel> ClassesLM       = new List <ClassesListModel>();

            foreach (PlayableClass playableClass in playableClasses)
            {
                ReadModelMapper <PlayableClass, ClassesListModel> mapper = new ReadModelMapper <PlayableClass, ClassesListModel>();
                ClassesListModel lm = mapper.mapDataModelToViewModel(playableClass);
                ClassesLM.Add(lm);
            }

            var expected = new ClassRowCM
            {
                Index            = 5,
                Level            = 1,
                RemainingHitDice = 1,
                playableClasses  = ClassesLM.ToArray()
            };

            using (var mockAccess = AutoMock.GetLoose())
            {
                mockAccess.Mock <IBaseUserAccess>()
                .Setup(x => x.GetAllPlayableClasses()).Returns(playableClasses);

                IBaseUserAccess access = mockAccess.Create <IBaseUserAccess>();
                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildNewClassRowCM(5);

                //Assert
                actual.Should().BeEquivalentTo(expected);
            }
        }
예제 #3
0
        public static ClassesCM GetNonNullClassesCM()
        {
            List <ClassesListModel> classes = new List <ClassesListModel>();

            foreach (PlayableClass pc in GetPlayableClasses())
            {
                ClassesListModel clm = new ClassesListModel
                {
                    Class_id = pc.Class_id,
                    Name     = pc.Name
                };
                classes.Add(clm);
            }

            ClassRowCM classRowCM = new ClassRowCM
            {
                playableClasses = classes.ToArray(),
                Index           = 1
            };

            ClassRowCM[] classesArray = new ClassRowCM[1];
            classesArray[0] = classRowCM;

            ClassesCM classesCM = new ClassesCM
            {
                SelectedClasses = classesArray
            };

            return(classesCM);
        }
예제 #4
0
        //Subclasses are not set in here, as that is planned to be handled dynamically by javascript getting only subclasses for the class.
        public ClassRowCM buildNewClassRowCM(int Index)
        {
            ReadModelMapper <PlayableClass, ClassesListModel> mapper = new ReadModelMapper <PlayableClass, ClassesListModel>();
            List <PlayableClass>    foundClasses = _userAccess.GetAllPlayableClasses().ToList();
            List <ClassesListModel> clm          = new List <ClassesListModel>();

            foreach (PlayableClass x in foundClasses)
            {
                ClassesListModel lm = mapper.mapDataModelToViewModel(x);
                clm.Add(lm);
            }

            ClassRowCM cm = new ClassRowCM
            {
                Index            = Index,
                Level            = 1,
                RemainingHitDice = 1,
                playableClasses  = clm.ToArray()
            };

            return(cm);
        }
        public void CreateCharacter_INVALID_ReferenceDataReset()
        {
            //Arrange
            var argument  = buildPOSTArgument();
            var Wizard_id = Guid.Parse("4e82620a-0496-4ecc-b6d4-05faa064310b");

            argument.PrimaryTab.Classes.SelectedClasses[0].SelectedClass_id = Wizard_id;

            var expected = argument;


            var selectableClasses = new List <ClassesListModel>();

            //set classes
            ReadModelMapper <PlayableClass, ClassesListModel> classesMapper = new ReadModelMapper <PlayableClass, ClassesListModel>();

            foreach (PlayableClass pc in CreateTestData.GetPlayableClasses())
            {
                ClassesListModel lm = classesMapper.mapDataModelToViewModel(pc);
                selectableClasses.Add(lm);
            }
            foreach (ClassRowCM cm in expected.PrimaryTab.Classes.SelectedClasses)
            {
                cm.playableClasses = selectableClasses.ToArray();

                //set subclasses
                List <SubclassesListModel> subclasses = new List <SubclassesListModel>();
                ReadModelMapper <Subclass, SubclassesListModel> subclassesMapper = new ReadModelMapper <Subclass, SubclassesListModel>();
                foreach (Subclass sc in CreateTestData.GetListOfSubclass().Where(x => x.Class_id == cm.SelectedClass_id))
                {
                    SubclassesListModel lm = subclassesMapper.mapDataModelToViewModel(sc);
                    subclasses.Add(lm);
                }
                cm.subclasses = subclasses.ToArray();
            }

            //set races
            ReadModelMapper <Race, RaceListModel> racesMapper = new ReadModelMapper <Race, RaceListModel>();
            List <RaceListModel> raceList = new List <RaceListModel>();

            foreach (Race r in CreateTestData.GetListOfRace())
            {
                RaceListModel lm = racesMapper.mapDataModelToViewModel(r);
            }

            //I need to obtain and replace the reference data for available races, classes, and subclasses.

            using (var mocks = AutoMock.GetLoose())
            {
                mocks.Mock <IBaseUserAccess>()
                .Setup(x => x.GetAllRaces()).Returns(CreateTestData.GetListOfRace());
                mocks.Mock <IBaseUserAccess>()
                .Setup(x => x.GetAllPlayableClasses()).Returns(CreateTestData.GetPlayableClasses());
                mocks.Mock <IBaseUserAccess>()
                .Setup(x => x.GetAllSubclassesForClass(Wizard_id))
                .Returns(CreateTestData.GetListOfSubclass().Where(x => x.Class_id == Wizard_id));

                mocks.Mock <ICharacterCommonFunctions>()
                .Setup(x => x.itemExists(Guid.NewGuid())).Returns(false);


                var access  = mocks.Create <IBaseUserAccess>();
                var commons = mocks.Create <ICharacterCommonFunctions>();

                //Act
                var toTest = ProcessorFactory.getCreateCharacterProcessor(access, commons);
                var actual = toTest.CreateCharacterINVALID(argument);

                actual.Should().BeEquivalentTo(expected);
            }
        }
예제 #6
0
        public void CMBuilder_buildKnownClassRowCM()
        {
            //Arrange
            var Wizard_id        = Guid.Parse("4e82620a-0496-4ecc-b6d4-05faa064310b");
            var Caleb_id         = Guid.Parse("361bd911-0702-437f-ab59-a29da0f9fba4");
            var Transmutation_id = Guid.Parse("c8d2e23a-a193-4e06-8814-9180d4830732");

            List <PlayableClass>    playableClasses = CreateTestData.GetPlayableClasses();
            List <ClassesListModel> ClassesLM       = new List <ClassesListModel>();

            foreach (PlayableClass playableClass in playableClasses)
            {
                ReadModelMapper <PlayableClass, ClassesListModel> mapper = new ReadModelMapper <PlayableClass, ClassesListModel>();
                ClassesListModel lm = mapper.mapDataModelToViewModel(playableClass);
                ClassesLM.Add(lm);
            }

            List <Subclass>            playableSubclasses = CreateTestData.GetListOfSubclass();
            List <SubclassesListModel> SubclassesLM       = new List <SubclassesListModel>();

            foreach (Subclass subclass in playableSubclasses.Where(x => x.Class_id == Wizard_id))
            {
                ReadModelMapper <Subclass, SubclassesListModel> mapper = new ReadModelMapper <Subclass, SubclassesListModel>();
                SubclassesListModel lm = mapper.mapDataModelToViewModel(subclass);
                SubclassesLM.Add(lm);
            }

            Character_Class_Subclass Caleb_Wizard_Transmutation = new Character_Class_Subclass
            {
                Character_id     = Guid.Parse("361bd911-0702-437f-ab59-a29da0f9fba4"),
                Class_id         = Guid.Parse("4e82620a-0496-4ecc-b6d4-05faa064310b"),
                Subclass_id      = Guid.Parse("c8d2e23a-a193-4e06-8814-9180d4830732"),
                RemainingHitDice = 12,
                ClassLevel       = 12
            };

            ClassRowCM expected = new ClassRowCM
            {
                Index            = 1,
                playableClasses  = ClassesLM.ToArray(),
                SelectedClass_id = Wizard_id,

                Level            = 12,
                RemainingHitDice = 12,

                subclasses          = SubclassesLM.ToArray(),
                SelectedSubclass_id = Transmutation_id
            };

            using (var mockAccess = AutoMock.GetLoose())
            {
                mockAccess.Mock <IBaseUserAccess>()
                .Setup(x => x.GetKnownClassRecordOfCharaterAndClass(Caleb_id, Wizard_id))
                .Returns(Caleb_Wizard_Transmutation);
                mockAccess.Mock <IBaseUserAccess>()
                .Setup(x => x.GetAllSubclassesForClass(Wizard_id))
                .Returns(playableSubclasses.Where(x => x.Class_id == Wizard_id));

                IBaseUserAccess access = mockAccess.Create <IBaseUserAccess>();
                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildKnownClassRowCM(1, Caleb_Wizard_Transmutation, ClassesLM.ToArray());

                //Assert
                actual.Should().BeEquivalentTo(expected);
            }
        }