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