public CoachesServiceTests()
        {
            DbContextOptionsBuilder <ApplicationDbContext> options =
                new DbContextOptionsBuilder <ApplicationDbContext>()
                .UseInMemoryDatabase(Guid.NewGuid().ToString());

            AutoMapperConfig.RegisterMappings(typeof(DetailsCoachViewModel).Assembly);

            this.applicationDbContext = new ApplicationDbContext(options.Options);
            this.skillsRepository     = new EfDeletableEntityRepository <Skill>(this.applicationDbContext);
            this.fightersRepository   = new EfDeletableEntityRepository <Fighter>(this.applicationDbContext);
            this.coachesRepository    = new EfDeletableEntityRepository <Coach>(this.applicationDbContext);
            this.skillsService        = new SkillsService(this.skillsRepository, this.usersRepository);
            this.coachesService       = new CoachesService(this.coachesRepository, this.fightersRepository, this.skillsService);

            foreach (var fighter in this.GetTestFighters())
            {
                this.fightersRepository.AddAsync(fighter);
                this.fightersRepository.SaveChangesAsync();
            }

            foreach (var coach in this.GetTestCoaches())
            {
                this.coachesRepository.AddAsync(coach);
                this.coachesRepository.SaveChangesAsync();
            }

            foreach (var skill in this.GetTestSkillPoints())
            {
                this.skillsRepository.AddAsync(skill);
                this.skillsRepository.SaveChangesAsync();
            }
        }
Exemple #2
0
 public CoachesController(ICoachesService coachesService, UserManager <ApplicationUser> userManager, IUsersService usersService, IDietsService dietsService)
 {
     this.coachesService = coachesService;
     this.userManager    = userManager;
     this.usersService   = usersService;
     this.dietsService   = dietsService;
 }
        public async Task GetServicesForBooking_Fail()
        {
            Setup();

            var qualification = new Qualification()
            {
                Id        = 1,
                CoachId   = 1,
                ServiceId = 1,
                Service   = new() { Id = 1 }
            };
            var qualifications = new List <Qualification>()
            {
                qualification
            };

            _applicationContextMock.Setup(x => x.Coaches).ReturnsDbSet(new List <Coach>());
            _applicationContextMock.Setup(x => x.Qualifications).ReturnsDbSet(qualifications);

            _testedService = new CoachesService(Logger, _applicationContextMock.Object);

            var result = await _testedService.GetCoaches(1, 1, CancellationToken.None);

            var listData = result.Data.ToList();

            Assert.Empty(listData);
        }
    }
        private void Setup()
        {
            var options = new DbContextOptionsBuilder <ApplicationContext>().Options;

            _applicationContextMock = new Mock <ApplicationContext>(options);
            _testedService          = new CoachesService(Logger, _applicationContextMock.Object);
        }
Exemple #5
0
 public CourseController(
     ICoachesService coachesService,
     ICoursesService coursesService,
     UserManager <ApplicationUser> userManager)
 {
     this.coachesService = coachesService;
     this.coursesService = coursesService;
     this.userManager    = userManager;
 }
 public CoachesController(
     ICoachesService coachesService,
     IFightersService fightersService,
     IUsersService usersService,
     UserManager <ApplicationUser> userManager)
 {
     this.coachesService  = coachesService;
     this.fightersService = fightersService;
     this.usersService    = usersService;
     this.userManager     = userManager;
 }
Exemple #7
0
 public WorkoutsService(
     ICloudinaryService cloudinaryService,
     IDeletableEntityRepository <Workout> workoutsRepository,
     IPositionsService positionsService,
     ICoachesService coachesService)
 {
     this.cloudinaryService  = cloudinaryService;
     this.workoutsRepository = workoutsRepository;
     this.positionsService   = positionsService;
     this.coachesService     = coachesService;
 }
Exemple #8
0
 public CoursesService(
     ICoachesService coachesService,
     IClientsService clientsService,
     IDeletableEntityRepository <Course> coursesRepository,
     IDeletableEntityRepository <CourseClients> courseClientsRepository,
     ICloudinaryService cloudinaryService)
 {
     this.coachesService          = coachesService;
     this.clientsService          = clientsService;
     this.coursesRepository       = coursesRepository;
     this.courseClientsRepository = courseClientsRepository;
     this.cloudinaryService       = cloudinaryService;
 }
Exemple #9
0
 public RegisterModel(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender,
     ICoachesService coachService,
     IClientsService clientService)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
     _coachService  = coachService;
     _clientService = clientService;
 }
 public UsersController(
     IUsersService usersService,
     UserManager <ApplicationUser> userManager,
     IFightersService fightersService,
     ISkillsService skillsService,
     IBiographiesService biographiesService,
     IManagersService managersService,
     ICoachesService coachesService,
     ICutmenService cutmenService)
 {
     this.usersService       = usersService;
     this.userManager        = userManager;
     this.fightersService    = fightersService;
     this.skillsService      = skillsService;
     this.biographiesService = biographiesService;
     this.managersService    = managersService;
     this.coachesService     = coachesService;
     this.cutmenService      = cutmenService;
 }
        public async Task GetServicesForBooking_Success()
        {
            Setup();

            var qualification = new Qualification()
            {
                Id        = 1,
                CoachId   = 1,
                ServiceId = 1,
                Service   = new() { Id = 1 }
            };
            var qualifications = new List <Qualification>()
            {
                qualification
            };
            var expectedCoach = new Coach()
            {
                Id = 1, FirstName = "TestSlot", Description = "top serv", Qualifications = qualifications
            };
            var coaches = new List <Coach>()
            {
                expectedCoach
            };

            _applicationContextMock.Setup(x => x.Coaches).ReturnsDbSet(coaches);
            _applicationContextMock.Setup(x => x.Qualifications).ReturnsDbSet(qualifications);

            _testedService = new CoachesService(Logger, _applicationContextMock.Object);

            var result = await _testedService.GetCoaches(1, 1, CancellationToken.None);

            var listData = result.Data.ToList();

            Assert.Single(listData);
            Assert.Equal(1, result.Paggination.TotalPages);
            Assert.Equal(1, result.Paggination.Page);
        }
 public CoachController(ICoachesService coachesService)
 {
     this.coachesService = coachesService;
 }
Exemple #13
0
 /// <summary>
 /// Constructor with DI.
 /// </summary>
 public CoachesController(ICoachesService coachesService)
 {
     _coachesService = coachesService;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CoachesController" /> class.
 /// </summary>
 /// <param name="coaches">Coaches interface.</param>
 public CoachesController(ICoachesService coaches)
 {
     _coaches = coaches;
 }