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 SubclassRepo_CharacterOfClassLearnsSubclass_ValidCall() { //Arrange List <Character_Class_Subclass> knownClasses = new List <Character_Class_Subclass>(); Character_Class_Subclass Caleb_Wizard_Blank = new Character_Class_Subclass { Character_id = Guid.Parse("11111111-2222-3333-4444-555555555555"), Class_id = Guid.Parse("4e82620a-0496-4ecc-b6d4-05faa064310b"), RemainingHitDice = 12, ClassLevel = 12 }; knownClasses.Add(Caleb_Wizard_Blank); var mockSet = new Mock <DbSet <Character_Class_Subclass> >() .SetupData(knownClasses, o => { return(knownClasses.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); var expected = CreateTestData.GetCharacter_Class_Subclass(); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <PlayableClassContext>() .Setup(x => x.KnownClasses).Returns(mockSet.Object); //Act var toTest = mockContext.Create <SubclassRepository>(); toTest.CharacterOfClassLearnsSubclass( Caleb_Wizard_Blank.Character_id, Caleb_Wizard_Blank.Class_id, Guid.Parse("c8d2e23a-a193-4e06-8814-9180d4830732")); var actual = knownClasses.First(); actual.Should().NotBeNull(); expected.Should().NotBeNull(); actual.Should().BeOfType <Character_Class_Subclass>(); expected.Should().BeOfType <Character_Class_Subclass>(); actual.Should().BeEquivalentTo(expected); } }
public void PlayableClassRepository_CharacterLearnsClass_ValidCall() { //Arrange List <Character_Class_Subclass> listofCharacter_Class_Subclass = new List <Character_Class_Subclass>(); var mockSet = new Mock <DbSet <Character_Class_Subclass> >() .SetupData(listofCharacter_Class_Subclass, o => { return(listofCharacter_Class_Subclass.Single(x => x.Class_id.CompareTo(o.First()) == 0)); }); var expected = CreateTestData.GetCharacter_Class_Subclass(); using (var mockContext = AutoMock.GetLoose()) { mockContext.Mock <PlayableClassContext>() .Setup(x => x.KnownClasses).Returns(mockSet.Object); //Act var toTest = mockContext.Create <PlayableClassRepository>(); toTest.CharacterLearnsClass(expected); //Assert listofCharacter_Class_Subclass.Should().ContainEquivalentOf(expected); } }