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);
            }
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
        }
Exemple #6
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);
            }
        }