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); } }
public void CharacterCommons_AddNoteToDb_ValidCall() { //Arrange List <Note> notes = new List <Note>(); var mockSet = new Mock <DbSet <Note> >() .SetupData(notes, o => { return(notes.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); Note expected = CreateTestData.GetSampleNote(); using (var mockContext = AutoMock.GetLoose()){ mockContext.Mock <CharacterContext>() .Setup(x => x.Notes).Returns(mockSet.Object); mockContext.Mock <CharacterContext>() .Setup(x => x.Set <Note>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); toTest.addNote(expected); notes.Should().ContainEquivalentOf(expected); } }
public void CharacterCommons_RemoveNonExistantItemFromHeldItems_ValidCall() { HeldItemRowCM[] heldItems = new HeldItemRowCM[2]; HeldItemRowCM[] expected = new HeldItemRowCM[1]; HeldItemRowCM realItem = new HeldItemRowCM { Item_id = CreateTestData.GetSampleItem().Item_id }; heldItems[0] = realItem; expected[0] = realItem; Guid false_id = Guid.Parse("96bd962c-5283-4f28-8a39-e82dbe01ff1a"); HeldItemRowCM fakeItem = new HeldItemRowCM { Item_id = false_id }; heldItems[1] = fakeItem; 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.removeNonExistantItemFromHeldItems(heldItems, false_id); //Assert actual.Should().BeEquivalentTo(expected); actual.Should().NotBeEquivalentTo(heldItems); } }
public void CharacterCommons_subclassExists_returnTrue() { //Arrange List <Subclass> subclasses = CreateTestData.GetListOfSubclass(); var mockSet = new Mock <DbSet <Subclass> >() .SetupData(subclasses, o => { return(subclasses.Single(x => x.Subclass_id.CompareTo(o.First()) == 0)); }); var realSubclass = CreateTestData.GetSubclass(); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <PlayableClassContext>() .Setup(x => x.Subclasses).Returns(mockSet.Object); mockContext.Mock <PlayableClassContext>() .Setup(x => x.Set <Subclass>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); var actual = toTest.subclassExists(realSubclass.Subclass_id); //Assert actual.Should().BeTrue(); } }
public void CharacterCommons_RemoveNonExistantClassIDFromSelectedClasses_ValidCall() { //Arrange Guid[] selectedClasses = new Guid[2]; Guid[] expected = new Guid[1]; var falseClass_id = Guid.Parse("96bd962c-5283-4f28-8a39-e82dbe01ff1a"); selectedClasses[0] = CreateTestData.GetSampleClass().Class_id; expected[0] = CreateTestData.GetSampleClass().Class_id; selectedClasses[1] = falseClass_id; 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.removeNonExistantClassIdFromSelectedClasses(selectedClasses, falseClass_id); //Assert actual.Should().BeEquivalentTo(expected); actual.Should().NotBeEquivalentTo(selectedClasses); } }
public void CharacterCommons_itemExists_returnTrue() { //Arrange List <Item> items = CreateTestData.GetListOfItems(); var mockSet = new Mock <DbSet <Item> >() .SetupData(items, o => { return(items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); var realItem = CreateTestData.GetSampleItem(); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(mockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); var actual = toTest.itemExists(realItem.Item_id); actual.Should().BeTrue(); } }
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 CharacterCommons_itemExists_returnFalse() { //Arrange List <Item> items = CreateTestData.GetListOfItems(); var mockSet = new Mock <DbSet <Item> >() .SetupData(items, o => { return(items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); var false_id = Guid.Parse("720f467c-7621-4dcf-a82f-7af50f253068"); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(mockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); Action act = () => toTest.itemExists(false_id); //Assert act.Should().Throw <InvalidOperationException>().WithMessage("Sequence contains no matching element"); } }
public void CharacterSerivces_buildHeldItemRowCM_ValidCall() { List <Item> items = CreateTestData.GetListOfItems(); var itemsMockSet = new Mock <DbSet <Item> >() .SetupData(items, o => { return(items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); HeldItemRowCM expected = CharacterMapper.mapItemToHeldItemRowCM(CreateTestData.GetSampleItem()); Item record = CreateTestData.GetSampleItem(); expected.Count = 1; expected.isAttuned = false; expected.isEquipped = false; expected.Index = 1; using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(itemsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(itemsMockSet.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.buildHeldItemRowCM(1, record.Item_id); actual.Should().BeEquivalentTo(expected); } }
public void CharacterCommons_CharacterObtainsItem_ValidCall() { //Arrange List <Character_Item> heldItems = new List <Character_Item>(); var mockSet = new Mock <DbSet <Character_Item> >() .SetupData(heldItems, o => { return(heldItems.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); Character_Item expected = new Character_Item { Character_id = CreateTestData.getSampleCharacter().Character_id, Item_id = CreateTestData.GetSampleItem().Item_id, count = 1 }; using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.HeldItems).Returns(mockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Character_Item>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); toTest.addHeldItemToDb(expected.Character_id, expected.Item_id); //Assert heldItems.Should().ContainEquivalentOf(expected); } }
public void CharacterCommons_CharacterLearnsClassSubclass_ValidCall() { List <Character_Class_Subclass> knownClasses = new List <Character_Class_Subclass>(); var mockSet = new Mock <DbSet <Character_Class_Subclass> >() .SetupData(knownClasses, o => { return(knownClasses.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); Character_Class_Subclass expected = CreateTestData.GetCharacter_Class_Subclass(); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <PlayableClassContext>() .Setup(x => x.KnownClasses).Returns(mockSet.Object); mockContext.Mock <PlayableClassContext>() .Setup(x => x.Set <Character_Class_Subclass>()).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); toTest.characterLearnsClass(expected); //Assert knownClasses.Should().ContainEquivalentOf(expected); } }
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 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); } }
public void CMBuilder_buildExistingHeldItemCM_ValidCall() { //Arrange List <Item> items = CreateTestData.GetListOfItems(); var itemMockSet = new Mock <DbSet <Item> >() .SetupData(items, o => { return(items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); List <Character_Item> heldItems = CreateTestData.GetListOfHeldItems(); var heldItemsMockSet = new Mock <DbSet <Character_Item> >() .SetupData(heldItems, o => { return(heldItems.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); Item item = CreateTestData.GetSampleItem(); Character_Item heldItem = CreateTestData.GetSampleHeldItem(); HeldItemRowCM expected = CharacterMapper.mapItemToHeldItemRowCM(item); CharacterMapper.mapHeldItemRecordToHeldItemRowCM(heldItem, expected); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(itemMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(itemMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Character_Item>()).Returns(heldItemsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.HeldItems).Returns(heldItemsMockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access); var actual = toTest.buildExistingHeldItemRowCM(heldItem.Character_id, heldItem.Item_id); actual.Should().BeEquivalentTo(expected); } }
public void CMBuilder_buildNoteCMsForCharacter_ValidCall() { List <Note> notes = CreateTestData.GetListOfNotes(); var mockSet = new Mock <DbSet <Note> >() .SetupData(notes, o => { return(notes.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); Guid Grog_id = Guid.Parse("11111111-2222-3333-4444-555555555555"); List <NoteCM> expected = new List <NoteCM>(); Guid Spelling_id = Guid.Parse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); Note spellingNote = notes.Find(x => x.Note_id == Spelling_id); NoteCM spellingCM = CharacterMapper.mapNoteToNoteCM(spellingNote); spellingCM.Index = 0; expected.Add(spellingCM); Guid GreatAxe_id = Guid.Parse("361bd911-0702-437f-ab59-a29da0f9fba4"); Note GreatAxeNote = notes.Find(x => x.Note_id == GreatAxe_id); NoteCM greatAxeCM = CharacterMapper.mapNoteToNoteCM(GreatAxeNote); greatAxeCM.Index = 1; expected.Add(greatAxeCM); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <CharacterContext>() .Setup(x => x.Set <Note>()).Returns(mockSet.Object); mockContext.Mock <CharacterContext>() .Setup(x => x.Notes).Returns(mockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access); var actual = toTest.buildNoteCMsFOrCharacter(Grog_id); //Assert actual.Should().BeEquivalentTo(expected); } }
public void CharacterCommons_spellCanBeCastByClass_returnFalse() { List <Spell_Class> spell_Classes = CreateTestData.GetListOfCastableByRecords(); List <Spell> spells = CreateTestData.GetListOfSpells(); var spellMockSet = new Mock <DbSet <Spell> >() .SetupData(spells, o => { return(spells.Single(x => x.Spell_id.CompareTo(o.First()) == 0)); }); var castableByMockSet = new Mock <DbSet <Spell_Class> >() .SetupData(spell_Classes, o => { return(spell_Classes.Single(x => x.Spell_id.CompareTo(o.First()) == 0)); }); var realSpellID = CreateTestData.GetSampleSpell().Spell_id; var falseClassID = Guid.Parse("16310468-2345-460f-a408-d9f7c908ad2a"); 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); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //act ICharacterCommonFunctions toTest = ProcessorFactory.GetCharacterCommonFunctions(access); var actual = toTest.spellCanBeCastByClass(realSpellID, falseClassID); //Assert actual.Should().BeFalse(); } }
public void CharacterServices_GetBlankNoteComponent_ValidCall() { var expected = new NoteCM(); expected.Index = 1; using (var mockContext = AutoMock.GetLoose()) { 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.GetBlankNoteComponent(1); //Assert actual.Should().BeEquivalentTo(expected); } }
public void CMBuilder_buildItemDetailsCM_ValidCall() { //Arrange List <Item> Items = CreateTestData.GetListOfItems(); List <Item_Tag> itemTags = CreateTestData.GetListOfItemTags(); List <Tag> tags = CreateTestData.GetListOfTags(); var ITmockSet = new Mock <DbSet <Item_Tag> >() .SetupData(itemTags, o => { return(itemTags.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); var tagsMockSet = new Mock <DbSet <Tag> >() .SetupData(tags, o => { return(tags.Single(x => x.Tag_id.CompareTo(o.First()) == 0)); }); var itemsMockSet = new Mock <DbSet <Item> >() .SetupData(Items, o => { return(Items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); Item Whisper = CreateTestData.GetSampleItem(); ItemDetailsCM expected = new ItemDetailsCM { Item_id = Whisper.Item_id, Name = Whisper.Name, Description = Whisper.Description, Value = Whisper.Value, isEquippable = Whisper.isEquippable, isConsumable = Whisper.isConsumable, requiresAttunement = Whisper.requiresAttunement }; String[] whisperTags = new string[2]; whisperTags[0] = "Weapon"; whisperTags[1] = "Wondorous Item"; expected.Tags = whisperTags; using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Tags).Returns(tagsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Tag>()).Returns(tagsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Item_Tags).Returns(ITmockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item_Tag>()).Returns(ITmockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(itemsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(itemsMockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access); var actual = toTest.buildItemDetailsCM(Whisper.Item_id); //Assert actual.Should().BeEquivalentTo(expected); } }
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); } }
public void CMBuilder_buildHeldItemRowCMsForCharacter_ValidCall() { List <Item> items = CreateTestData.GetListOfItems(); var itemMockSet = new Mock <DbSet <Item> >() .SetupData(items, o => { return(items.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); List <Character_Item> heldItems = CreateTestData.GetListOfHeldItems(); var heldItemsMockSet = new Mock <DbSet <Character_Item> >() .SetupData(heldItems, o => { return(heldItems.Single(x => x.Item_id.CompareTo(o.First()) == 0)); }); List <HeldItemRowCM> expected = new List <HeldItemRowCM>(); Item Whisper = CreateTestData.GetSampleItem(); Character_Item VaxHoldsWhisper = CreateTestData.GetSampleHeldItem(); HeldItemRowCM Vax_Whisper = CharacterMapper.mapItemToHeldItemRowCM(Whisper); CharacterMapper.mapHeldItemRecordToHeldItemRowCM(VaxHoldsWhisper, Vax_Whisper); Vax_Whisper.Index = 0; expected.Add(Vax_Whisper); Item HealingPotion = new Item { Item_id = Guid.Parse("2caa23dc-15e6-4a57-9bb6-62f6d8636ff7"), Name = "Healing potion", Description = "Upon consumption of the whole potion, the imbiber heals for 2d4+2 health.", isEquippable = false, isConsumable = true, requiresAttunement = false, Value = 50 }; Character_Item VaxHoldsPotions = new Character_Item { Character_id = Guid.Parse("e3a0faef-99da-4d15-bff1-b535a42b955c"), Item_id = Guid.Parse("2caa23dc-15e6-4a57-9bb6-62f6d8636ff7"), count = 3 }; HeldItemRowCM Vax_Potions = CharacterMapper.mapItemToHeldItemRowCM(HealingPotion); CharacterMapper.mapHeldItemRecordToHeldItemRowCM(VaxHoldsPotions, Vax_Potions); Vax_Potions.Index = 1; expected.Add(Vax_Potions); Guid Vax_id = Guid.Parse("e3a0faef-99da-4d15-bff1-b535a42b955c"); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Item>()).Returns(itemMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Items).Returns(itemMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.Set <Character_Item>()).Returns(heldItemsMockSet.Object); mockContext.Mock <ItemsContext>() .Setup(x => x.HeldItems).Returns(heldItemsMockSet.Object); IUnitOfWork uow = UoW_Factory.getUnitofWork(mockContext); IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow); //Act ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access); var actual = toTest.buildItemRowCMsForCharacter(Vax_id); actual.Should().BeEquivalentTo(expected); } }
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); } }