public void CharacterCommons_RemoveNonExistantSpellFromKnownSpells_ValidCall()
        {
            //Arrange
            List <KnownSpellRowCM> KnownSpellRowCMs = new List <KnownSpellRowCM>();
            List <KnownSpellRowCM> expected         = new List <KnownSpellRowCM>();

            KnownSpellRowCM realSpell = new KnownSpellRowCM()
            {
                Spell_id = CreateTestData.GetSampleSpell().Spell_id
            };

            expected.Add(realSpell);
            KnownSpellRowCMs.Add(realSpell);
            KnownSpellRowCM fakeSpell = new KnownSpellRowCM()
            {
                Spell_id = Guid.Parse("96bd962c-5283-4f28-8a39-e82dbe01ff1a")
            };

            KnownSpellRowCMs.Add(fakeSpell);
            KnownSpellRowCM[] knownSpellArray = KnownSpellRowCMs.ToArray();

            using (var mockContext = AutoMock.GetLoose())
            {
                IUnitOfWork     uow    = UoW_Factory.getUnitofWork(mockContext);
                IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow);

                //act
                ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access);
                var actual = toTest.removeNonExistantSpellCMFromKnownSpells(knownSpellArray, fakeSpell.Spell_id);

                //Assert
                actual.Should().BeEquivalentTo(expected.ToArray());
            }
        }
        public void CharacterServices_buildKnownSpellRowCM_ValidCall()
        {
            //Arrange
            List <Spell> spells  = CreateTestData.GetListOfSpells();
            var          mockSet = new Mock <DbSet <Spell> >()
                                   .SetupData(spells, o =>
            {
                return(spells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });
            var             record   = CreateTestData.GetSampleSpell();
            KnownSpellRowCM expected = CharacterMapper.mapSpellToKnownSpellRowCM(record);

            expected.Index = 1;

            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Spell>()).Returns(mockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Spells).Returns(mockSet.Object);

                IUnitOfWork     uow     = UoW_Factory.getUnitofWork(mockContext);
                IBaseUserAccess access  = UserAccessFactory.getBaseUserAccess(uow);
                var             creator = ProcessorFactory.getCreateCharacterProcessor(access);
                var             updater = ProcessorFactory.getUpdateCharacterProcessor(access);
                var             builder = ProcessorFactory.GetCharacterCMBuilder(access);

                //Act
                var toTest = ServicesFactory.GetCharacterService(creator, updater, builder);
                var actual = toTest.buildKnownSpellRowCM(1, record.Spell_id);
            }
        }
        public KnownSpellRowCM buildKnownSpellRowCM(int Index, Guid Spell_id)
        {
            KnownSpellRowCM cm = _builder.buildKnownSpellRowCM(Spell_id);

            cm.Index = Index;
            return(cm);
        }
Пример #4
0
        public KnownSpellRowCM buildKnownSpellRowCM(Guid Spell_id)
        {
            Spell           foundSpell = _userAccess.GetSpell(Spell_id);
            KnownSpellRowCM cm         = CharacterMapper.mapSpellToKnownSpellRowCM(foundSpell);

            cm.School = _userAccess.GetSchool(foundSpell.School_id).Name;
            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);
        }
        private void GetBlankSpellsTab(CharacterVM vm)
        {
            SpellsTabVM spellsTab = new SpellsTabVM();

            KnownSpellRowCM[] KnownSpells = new KnownSpellRowCM[0];
            spellsTab.KnownSpells = KnownSpells;

            vm.SpellsTab = spellsTab;
        }
        //------Delete------
        public KnownSpellRowCM[] removeNonExistantSpellCMFromKnownSpells(KnownSpellRowCM[] knownSpellCMs, Guid falseSpell_id)
        {
            List <KnownSpellRowCM> listOfCM   = knownSpellCMs.ToList();
            KnownSpellRowCM        falseSpell = listOfCM.Where(x => x.Spell_id == falseSpell_id).FirstOrDefault();

            if (falseSpell != null)
            {
                listOfCM.Remove(falseSpell);
            }
            return(listOfCM.ToArray());
        }
Пример #8
0
        public void CharacterMapper_mapSpellToKnownSpellRowCM_ValidCall()
        {
            var record   = CreateTestData.GetSampleSpell();
            var expected = new KnownSpellRowCM();

            expected.Spell_id   = record.Spell_id;
            expected.Name       = record.Name;
            expected.School     = null;
            expected.Level      = record.Level;
            expected.isPrepared = false;

            var actual = CharacterMapper.mapSpellToKnownSpellRowCM(record);

            actual.Should().BeEquivalentTo(expected);
        }
Пример #9
0
        public void CMBuilder_buildKnownSpellRowCM_ValidCall()
        {
            //Arrange
            List <Spell> spells        = CreateTestData.GetListOfSpells();
            var          spellsMockSet = new Mock <DbSet <Spell> >()
                                         .SetupData(spells, o =>
            {
                return(spells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });
            List <School> spellSchools   = CreateTestData.GetListOfSchools();
            var           schoolsMockSet = new Mock <DbSet <School> >()
                                           .SetupData(spellSchools, o =>
            {
                return(spellSchools.Single(x => x.School_id.CompareTo(o.First()) == 0));
            });

            Guid Tower_id = Guid.Parse("46d10bb8-84d2-408d-a928-5847ff99461f");
            var  Tower    = spells.Find(x => x.Spell_id == Tower_id);

            KnownSpellRowCM expected = CharacterMapper.mapSpellToKnownSpellRowCM(Tower);

            expected.School = "Conjuration";
            expected.Index  = 0;


            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Spell>()).Returns(spellsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Spells).Returns(spellsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <School>()).Returns(schoolsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Schools).Returns(schoolsMockSet.Object);

                IUnitOfWork     uow    = UoW_Factory.getUnitofWork(mockContext);
                IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow);

                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildKnownSpellRowCM(Tower.Spell_id);

                //Assert
                actual.Should().BeEquivalentTo(expected);
            }
        }
Пример #10
0
        public IEnumerable <KnownSpellRowCM> buildKnownSpellRowCMsForCharacter(Guid Character_id)
        {
            List <Spell_Character> knownSpells = _userAccess.GetKnownSpellRecordsForCharacter(Character_id).ToList();
            List <KnownSpellRowCM> CMs         = new List <KnownSpellRowCM>();
            int i = 0;

            foreach (Spell_Character knownSpell in knownSpells)
            {
                Spell  foundSpell  = _userAccess.GetSpell(knownSpell.Spell_id);
                School foundSchool = _userAccess.GetSchool(foundSpell.School_id);

                KnownSpellRowCM cm = CharacterMapper.mapSpellToKnownSpellRowCM(foundSpell);
                cm.Index  = i;
                cm.School = foundSchool.Name;
                i++;
                CMs.Add(cm);
            }
            return(CMs);
        }
Пример #11
0
        public void CMBuilder_buildKnownSpellRowCMsForCharacter_ValidCall()
        {
            //Arrange
            List <Spell> spells        = CreateTestData.GetListOfSpells();
            var          spellsMockSet = new Mock <DbSet <Spell> >()
                                         .SetupData(spells, o =>
            {
                return(spells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });

            List <Spell_Character> knownSpells = CreateTestData.GetListOfKnownSpells();
            var knownSpellsMockSet             = new Mock <DbSet <Spell_Character> >()
                                                 .SetupData(knownSpells, o =>
            {
                return(knownSpells.Single(x => x.Character_id.CompareTo(o.First()) == 0));
            });

            List <School> spellSchools   = CreateTestData.GetListOfSchools();
            var           schoolsMockSet = new Mock <DbSet <School> >()
                                           .SetupData(spellSchools, o =>
            {
                return(spellSchools.Single(x => x.School_id.CompareTo(o.First()) == 0));
            });


            //Caleb knows both his tower and Web of Fire, so we want to return CMs for both spells.
            Guid Caleb_id = Guid.Parse("11111111-2222-3333-4444-555555555555");

            List <KnownSpellRowCM> expected = new List <KnownSpellRowCM>();
            Guid            Tower_id        = Guid.Parse("46d10bb8-84d2-408d-a928-5847ff99461f");
            var             Tower           = spells.Find(x => x.Spell_id == Tower_id);
            KnownSpellRowCM TowerRow        = CharacterMapper.mapSpellToKnownSpellRowCM(Tower);

            TowerRow.School = "Conjuration";
            TowerRow.Index  = 0;
            expected.Add(TowerRow);

            Guid            WoF_id       = Guid.Parse("51b4c563-2040-4c7d-a23e-cab8d5d3c73b");
            var             WebOfFire    = spells.Find(x => x.Spell_id == WoF_id);
            KnownSpellRowCM WebOfFireRow = CharacterMapper.mapSpellToKnownSpellRowCM(WebOfFire);

            WebOfFireRow.School = "Evocation";
            WebOfFireRow.Index  = 1;
            expected.Add(WebOfFireRow);



            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Spell>()).Returns(spellsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Spells).Returns(spellsMockSet.Object);

                mockContext.Mock <SpellsContext>()
                .Setup(x => x.KnownSpells).Returns(knownSpellsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Spell_Character>()).Returns(knownSpellsMockSet.Object);

                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <School>()).Returns(schoolsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Schools).Returns(schoolsMockSet.Object);

                IUnitOfWork     uow    = UoW_Factory.getUnitofWork(mockContext);
                IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow);

                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildKnownSpellRowCMsForCharacter(Caleb_id);

                //Assert
                actual.Should().BeEquivalentTo(expected);
            }
        }
Пример #12
0
        public static void mapSpellToKnownSpellRowCM(Spell m, KnownSpellRowCM cm)
        {
            ReadModelMapper <Spell, KnownSpellRowCM> mapper = new ReadModelMapper <Spell, KnownSpellRowCM>();

            mapper.mapDataModelToViewModel(m, cm);
        }