private foundSpellCM buildFoundSpellCM(Spell spell) { ReadModelMapper <Spell, foundSpellCM> mapper = new ReadModelMapper <Spell, foundSpellCM>(); foundSpellCM cm = mapper.mapDataModelToViewModel(spell); return(cm); }
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); } }
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(); } } }
public ClassRowCM buildKnownClassRowCM(int Index, Character_Class_Subclass ccsc, ClassesListModel[] CLM) { // Takes the set of list models as an argument, as //being passed references to the same set is more efficient than searching and obtaining the set again and again. //Still have to search for each class' subclasses, as that changes depending on the class. ReadModelMapper <Subclass, SubclassesListModel> subclassMapper = new ReadModelMapper <Subclass, SubclassesListModel>(); List <Subclass> foundSubclasses = _userAccess.GetAllSubclassesForClass(ccsc.Class_id).ToList(); List <SubclassesListModel> sclm = new List <SubclassesListModel>(); foreach (Subclass x in foundSubclasses) { SubclassesListModel lm = subclassMapper.mapDataModelToViewModel(x); sclm.Add(lm); } ClassRowCM cm = new ClassRowCM { Index = Index, playableClasses = CLM, SelectedClass_id = ccsc.Class_id, Level = ccsc.ClassLevel, RemainingHitDice = ccsc.RemainingHitDice, subclasses = sclm.ToArray(), SelectedSubclass_id = ccsc.Subclass_id }; return(cm); }
private foundItemCM buildFoundItemCM(Item item) { ReadModelMapper <Item, foundItemCM> mapper = new ReadModelMapper <Item, foundItemCM>(); foundItemCM cm = mapper.mapDataModelToViewModel(item); return(cm); }
public static HeldItemRowCM mapItemToHeldItemRowCM(Item m) { ReadModelMapper <Item, HeldItemRowCM> mapper = new ReadModelMapper <Item, HeldItemRowCM>(); HeldItemRowCM cm = new HeldItemRowCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static NoteCM mapNoteToNoteCM(Note m) { ReadModelMapper <Note, NoteCM> mapper = new ReadModelMapper <Note, NoteCM>(); NoteCM cm = new NoteCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static IsProficientCM mapIsProficientToIsProficientCM(IsProficient m) { ReadModelMapper <IsProficient, IsProficientCM> mapper = new ReadModelMapper <IsProficient, IsProficientCM>(); IsProficientCM cm = new IsProficientCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static SpellDetailsCM mapSpellToSpellDetailsCM(Spell m) { ReadModelMapper <Spell, SpellDetailsCM> mapper = new ReadModelMapper <Spell, SpellDetailsCM>(); SpellDetailsCM cm = new SpellDetailsCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static KnownSpellRowCM mapSpellToKnownSpellRowCM(Spell m) { ReadModelMapper <Spell, KnownSpellRowCM> mapper = new ReadModelMapper <Spell, KnownSpellRowCM>(); KnownSpellRowCM cm = new KnownSpellRowCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static ItemDetailsCM mapItemToItemDetailsCM(Item m) { ReadModelMapper <Item, ItemDetailsCM> mapper = new ReadModelMapper <Item, ItemDetailsCM>(); ItemDetailsCM cm = new ItemDetailsCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public static HeldItemRowCM mapHeldItemRecordToHeldItemRowCM(Character_Item m) { ReadModelMapper <Character_Item, HeldItemRowCM> mapper = new ReadModelMapper <Character_Item, HeldItemRowCM>(); HeldItemRowCM cm = new HeldItemRowCM(); mapper.mapDataModelToViewModel(m, cm); return(cm); }
public IsProficientCM buildIsProficientCM(Guid Character_id) { IsProficient foundRecord = _userAccess.GetProficiencyRecord(Character_id); ReadModelMapper <IsProficient, IsProficientCM> mapper = new ReadModelMapper <IsProficient, IsProficientCM>(); IsProficientCM cm = mapper.mapDataModelToViewModel(foundRecord); return(cm); }
public StatsCM buildStatsCM(Guid Character_id) { ReadModelMapper <Stats, StatsCM> mapper = new ReadModelMapper <Stats, StatsCM>(); Stats foundStats = _userAccess.GetStatsRecord(Character_id); StatsCM cm = mapper.mapDataModelToViewModel(foundStats); return(cm); }
//Read public static RaceListModel mapRaceToRaceListModel(Race model) { ReadModelMapper <Race, RaceListModel> mapper = new ReadModelMapper <Race, RaceListModel>(); RaceListModel lm = new RaceListModel(); mapper.mapDataModelToViewModel(model, lm); return(lm); }
//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 static void mapItemToHeldItemRowCM(Item m, HeldItemRowCM cm) { ReadModelMapper <Item, HeldItemRowCM> mapper = new ReadModelMapper <Item, HeldItemRowCM>(); mapper.mapDataModelToViewModel(m, 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); } }
public static void mapItemToItemDetailsCM(Item m, ItemDetailsCM cm) { ReadModelMapper <Item, ItemDetailsCM> mapper = new ReadModelMapper <Item, ItemDetailsCM>(); mapper.mapDataModelToViewModel(m, cm); }
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); } }
public static void mapSpellToKnownSpellRowCM(Spell m, KnownSpellRowCM cm) { ReadModelMapper <Spell, KnownSpellRowCM> mapper = new ReadModelMapper <Spell, KnownSpellRowCM>(); mapper.mapDataModelToViewModel(m, cm); }
public static void mapHeldItemRecordToHeldItemRowCM(Character_Item m, HeldItemRowCM cm) { ReadModelMapper <Character_Item, HeldItemRowCM> mapper = new ReadModelMapper <Character_Item, HeldItemRowCM>(); mapper.mapDataModelToViewModel(m, cm); }