public SpellDetailsCM GetSpellDetailsCM(Guid Spell_id)
 {
     return(_builder.buildSpellDetailsCM(Spell_id));
 }
Beispiel #2
0
        public void CMBUilder_buildSpellDetailsCM_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));
            });
            List <Material> materials        = CreateTestData.GetListOfMaterials();
            var             materialsMockSet = new Mock <DbSet <Material> >()
                                               .SetupData(materials, o =>
            {
                return(materials.Single(x => x.Spell_id.CompareTo(o.First()) == 0));
            });


            var VoltaicBolt_id = Guid.Parse("a9756f3d-55d0-40cd-8083-6b547e4932ab");

            //I expect to get the details CM for Brenatto's Voltaic Bolt
            var expected = new SpellDetailsCM
            {
                Spell_id              = Guid.Parse("a9756f3d-55d0-40cd-8083-6b547e4932ab"),
                Name                  = "Brenatto's Voltaic Bolt",
                Description           = "The caster's next ranged attack deals an additional 3d6 lightning damage",
                Level                 = 1,
                School                = "Evocation",
                CastingTime           = "1 Bonus Action",
                Duration              = "1 round",
                Range                 = "30 feet",
                RequiresVerbal        = false,
                RequiresSomantic      = true,
                RequiresMaterial      = true,
                RequiresConcentration = false,
                Material              = "A bit of fleece"
            };

            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);

                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Materials).Returns(materialsMockSet.Object);
                mockContext.Mock <SpellsContext>()
                .Setup(x => x.Set <Material>()).Returns(materialsMockSet.Object);

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

                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildSpellDetailsCM(VoltaicBolt_id);

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