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_subclassExists_returnFalse()
        {
            //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 false_id = Guid.Parse("720f467c-7621-4dcf-a82f-7af50f253068");

            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);
                Action act = () => toTest.subclassExists(false_id);

                //Assert
                act.Should().Throw <InvalidOperationException>().WithMessage("Sequence contains no matching element");
            }
        }
        private void SetClasses(IEnumerable <ClassRowCM> selectedClasses, Guid Character_id)
        {
            CreateModelMapper <ClassRowCM, Character_Class_Subclass> mapper = new CreateModelMapper <ClassRowCM, Character_Class_Subclass>();
            List <Guid> alreadyLearnedClasses = new List <Guid>();

            foreach (ClassRowCM cm in selectedClasses)
            {
                //Check if the classes the player selected exist, if the selected sublcass exists, if the player hasn't already selected this class,
                //and if the selected subclass belongs to the selected class.
                if (_commons.playableClassExists(cm.SelectedClass_id) && _commons.subclassExists(cm.SelectedSubclass_id) &&
                    _commons.subclassIsOfClass(cm.SelectedSubclass_id, cm.SelectedClass_id) &&
                    alreadyLearnedClasses.Contains(cm.SelectedClass_id) == false)
                {
                    Character_Class_Subclass record = mapper.mapViewModelToDataModel(cm);
                    record.Character_id = Character_id;
                    alreadyLearnedClasses.Add(record.Class_id);
                    _userAccess.CharacterLearnsClass(record);
                }
                else
                {
                    continue;
                }
            }
        }