public void CharacterCommons_CharacterLearnsSpell_ValidCall()
        {
            //Arrange
            List <Spell_Character> knownSpells = new List <Spell_Character>();
            var mockSet = new Mock <DbSet <Spell_Character> >()
                          .SetupData(knownSpells, o =>
            {
                return(knownSpells.Single(x => x.Character_id.CompareTo(o.First()) == 0));
            });
            Spell_Character expected = CreateTestData.GetSampleKnownSpell();

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

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

                //act
                ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access);
                toTest.characterLearnsSpell(expected.Character_id, expected.Spell_id);

                //Assert
                knownSpells.Should().ContainEquivalentOf(expected);
            }
        }
Exemplo n.º 2
0
        public void SpellsRepository_CharacterLearnsSpell_ByRecord_ValidCall()
        {
            //Arrange
            List <Spell_Character> KnownSpells = new List <Spell_Character>();
            var mockKnownSpells = new Mock <DbSet <Spell_Character> >()
                                  .SetupData(KnownSpells, o =>
            {
                return(KnownSpells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });

            Spell_Character expected = new Spell_Character
            {
                Character_id = Guid.Parse("11111111-2222-3333-4444-555555555555"),
                Spell_id     = Guid.Parse("45c1a8cc-2e3e-4e29-8eeb-f9fa0cc9e27e"),
                isPrepared   = true
            };

            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.KnownSpells).Returns(mockKnownSpells.Object);

                //Act
                ISpellsRepository toTest = mockContext.Create <SpellsRepository>();
                toTest.CharacterLearnsSpell(expected);

                var actual = KnownSpells.First();

                //assert
                actual.Should().BeEquivalentTo(expected);
            }
        }
Exemplo n.º 3
0
        public static List <Spell_Character> GetListOfKnownSpells()
        {
            List <Spell_Character> knownSpells = new List <Spell_Character>();

            var Caleb_Tower = GetSampleKnownSpell();

            knownSpells.Add(Caleb_Tower);

            Spell_Character Caleb_WebOfFire = new Spell_Character()
            {
                Character_id = Guid.Parse("11111111-2222-3333-4444-555555555555"),
                Spell_id     = Guid.Parse("51b4c563-2040-4c7d-a23e-cab8d5d3c73b")
            };

            knownSpells.Add(Caleb_WebOfFire);

            Spell_Character Veth_VoltaicBolt = new Spell_Character()
            {
                Character_id = Guid.Parse("9aa6cd47-d784-46e4-9b66-7b1ea10d3386"),
                Spell_id     = Guid.Parse("a9756f3d-55d0-40cd-8083-6b547e4932ab")
            };

            knownSpells.Add(Veth_VoltaicBolt);

            Spell_Character Veth_MageHand = new Spell_Character()
            {
                Character_id = Guid.Parse("9aa6cd47-d784-46e4-9b66-7b1ea10d3386"),
                Spell_id     = Guid.Parse("a678034d-730c-4b86-a952-c975c04c6291")
            };

            knownSpells.Add(Veth_MageHand);

            return(knownSpells);
        }
        public void CharacterForgetsSpell(Guid Character_id, Guid Spell_id)
        {
            Spell_Character foundRecord = (from S_C in spellsContext.KnownSpells
                                           where S_C.Spell_id == Spell_id & S_C.Character_id == Character_id
                                           select S_C).First();

            spellsContext.KnownSpells.Remove(foundRecord);
        }
        public void CharacterLearnsSpell(Guid Character_id, Guid Spell_id)
        {
            Spell_Character learnedSpell = new Spell_Character
            {
                Spell_id     = Spell_id,
                Character_id = Character_id
            };

            spellsContext.KnownSpells.Add(learnedSpell);
        }
Exemplo n.º 6
0
        public static Spell_Character GetSampleKnownSpell()
        {
            Spell_Character Caleb_tower = new Spell_Character()
            {
                Character_id = Guid.Parse("11111111-2222-3333-4444-555555555555"),
                Spell_id     = Guid.Parse("46d10bb8-84d2-408d-a928-5847ff99461f")
            };

            return(Caleb_tower);
        }
        private bool CharacterAlreadyKnowsSpell(Guid Character_id, Guid spell_id)
        {
            Spell_Character foundRecord = _userAccess.GetKnownSpellRecord(Character_id, spell_id);

            if (foundRecord != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void LearnSpells(IEnumerable <KnownSpellRowCM> knownSpells, Guid character_id)
        {
            CreateModelMapper <KnownSpellRowCM, Spell_Character> mapper = new CreateModelMapper <KnownSpellRowCM, Spell_Character>();
            List <Guid> alreadyLearned = new List <Guid>();

            foreach (KnownSpellRowCM cm in knownSpells)
            {
                if (_commons.spellExists(cm.Spell_id) && alreadyLearned.Contains(cm.Spell_id) == false)
                {
                    Spell_Character record = mapper.mapViewModelToDataModel(cm);
                    record.Character_id = character_id;
                    _userAccess.CharacterLearnsSpell(record);
                    alreadyLearned.Add(cm.Spell_id);
                }
                else
                {
                    continue;
                }
            }
        }
Exemplo n.º 9
0
        public void SpellsRepository_GetKnownSpellRecordsForCharacter_ValidCall()
        {
            List <Spell_Character> knownSpells = CreateTestData.GetListOfKnownSpells();
            var mockSet = new Mock <DbSet <Spell_Character> >()
                          .SetupData(knownSpells, o =>
            {
                return(knownSpells.Single(x => x.Character_id.CompareTo(o.First()) == 0));
            });

            List <Spell_Character> expected    = new List <Spell_Character>();
            Spell_Character        Caleb_Tower = CreateTestData.GetSampleKnownSpell();

            expected.Add(Caleb_Tower);

            Spell_Character Caleb_WebOfFire = new Spell_Character()
            {
                Character_id = Guid.Parse("11111111-2222-3333-4444-555555555555"),
                Spell_id     = Guid.Parse("51b4c563-2040-4c7d-a23e-cab8d5d3c73b")
            };

            expected.Add(Caleb_WebOfFire);

            Guid Caleb_id = Guid.Parse("11111111-2222-3333-4444-555555555555");

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

                //Act
                ISpellsRepository toTest = mockContext.Create <SpellsRepository>();
                var actual = toTest.GetKnownSpellRecordsForCharacter(Caleb_id);

                //Arrange
                actual.Should().BeEquivalentTo(expected);
            }
        }
Exemplo n.º 10
0
 public void CharacterLearnsSpell(Spell_Character record)
 {
     _worker.Spells.CharacterLearnsSpell(record);
 }
Exemplo n.º 11
0
 public void CharacterLearnsSpell(Spell_Character record)
 {
     spellsContext.KnownSpells.Add(record);
 }
        public void CharacterServices_ExistingCharacterLearnsSpell_ValidCall()
        {
            //Arrange
            List <Spell>       listOfSpells     = CreateTestData.GetListOfSpells();
            List <Spell_Class> listOfCastableBy = CreateTestData.GetListOfCastableByRecords();
            List <Character_Class_Subclass> listofKnownClasses = CreateTestData.GetListOfCharacter_Class_Subclass();
            List <Spell_Character>          listOfKnownSpells  = new List <Spell_Character>();

            //Caleb should learn how to cast his tower spell.
            Spell_Character expected = CreateTestData.GetSampleKnownSpell();
            Guid            Caleb_id = expected.Character_id;
            Guid            User_id  = Guid.Parse("5f0d6374-fe3e-4337-9a0a-787db1f7b628");
            Guid            Tower_id = expected.Spell_id;

            var spellMockSet = new Mock <DbSet <Spell> >()
                               .SetupData(listOfSpells, o =>
            {
                return(listOfSpells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });
            var castableByMockSet = new Mock <DbSet <Spell_Class> >()
                                    .SetupData(listOfCastableBy, o =>
            {
                return(listOfCastableBy.Single(x => x.Class_id.CompareTo(o.First()) == 0));
            });
            var knownClassesMockSet = new Mock <DbSet <Character_Class_Subclass> >()
                                      .SetupData(listofKnownClasses, o =>
            {
                return(listofKnownClasses.Single(x => x.Character_id.CompareTo(o.First()) == 0));
            });
            var knownSpellsMockSet = new Mock <DbSet <Spell_Character> >()
                                     .SetupData(listOfKnownSpells, o =>
            {
                return(listOfKnownSpells.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });

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

                mockContext.Mock <SpellsContext>()
                .Setup(x => x.CastableByRecords).Returns(castableByMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Spell_Class>()).Returns(castableByMockSet.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 <PlayableClassContext>()
                .Setup(x => x.KnownClasses).Returns(knownClassesMockSet.Object);
                mockContext.Mock <PlayableClassContext>()
                .Setup(x => x.Set <Character_Class_Subclass>()).Returns(knownClassesMockSet.Object);

                //Act
                ICharacterServices toTest = mockContext.Create <CharacterServices>();
                toTest.ExistingCharacterLearnsSpell(User_id, Caleb_id, Tower_id);

                //Assert
                listOfKnownSpells.Should().ContainEquivalentOf(expected);
                listOfKnownSpells.Where(x => x.Spell_id == expected.Spell_id && x.Character_id == expected.Character_id).Count().Should().Be(1);
            }
        }