Ejemplo n.º 1
0
        public static void Initialize(TestContext testContext)
        {
            PuzzleGenerator <SudokuPuzzle> sudokuGenerator = new SudokuGenerator();
            PuzzlePrinter <SudokuPuzzle>   sudokuPrinter   = new SudokuPrinter();

            _sudokuPuzzleService = new SudokuPuzzleService(sudokuGenerator, sudokuPrinter);
        }
 public PlayersController(IAccountService accountService, IPuzzleService puzzleService, IAuthenticationService authenticationService, IWebSnapshotService snapshotService)
 {
     _accountService = accountService;
     _puzzleService = puzzleService;
     _authenticationService = authenticationService;
     _snapshotService = snapshotService;
 }
Ejemplo n.º 3
0
 public PuzzlesController(
     UserManager <User> userManager,
     IPuzzleService puzzles)
 {
     this.userManager = userManager;
     this.puzzles     = puzzles;
 }
 public PuzzlesController(IPuzzleService puzzleService, IAuthenticationService authenticationService, IAccountService accountService, ITwitterService twitterService)
 {
     _puzzleService = puzzleService;
     _authenticationService = authenticationService;
     _accountService = accountService;
     _twitterService = twitterService;
 }
Ejemplo n.º 5
0
 public PuzzleHandler(
     WebSocketConnectionManager webSocketConnectionManager,
     IPuzzleService <SudokuPuzzle> sudokuPuzzleService,
     IPuzzleStorageService puzzleStorageService) : base(webSocketConnectionManager)
 {
     _sudokuPuzzleService  = sudokuPuzzleService;
     _puzzleStorageService = puzzleStorageService;
 }
Ejemplo n.º 6
0
 public PartsController(IPartService parts,
                        IPuzzleService puzzles,
                        UserManager <User> userManager)
 {
     this.parts       = parts;
     this.puzzles     = puzzles;
     this.userManager = userManager;
 }
Ejemplo n.º 7
0
 public PuzzleZdaniaViewModel(ISatzeService satzeService, IPuzzleService puzzleService, IDialogService dialogService)
 {
     InitializeServices();
     _timer.RunServiceAsync(); //todo on command
     this.satzeService  = satzeService;
     this.puzzleService = puzzleService;
     this.dialogService = dialogService;
     // this.dialogService.ShowMessageBox(this, "KONIEC - powiedz SKOŃCZYŁEM!");
     this.openDialogCommand = new RelayCommand(OnOpenDialog);
 }
Ejemplo n.º 8
0
 public GameService(ITopicService topicService, IAuthenticationService authenticationService, IAccountService accountService, IPuzzleService puzzleService, IPuzzleCache puzzleCache, IRepository repository, IReputationService reputationService, IMessengerService twitterService)
 {
     _topicService = topicService;
     _authenticationService = authenticationService;
     _accountService = accountService;
     _puzzleService = puzzleService;
     _puzzleCache = puzzleCache;
     _repository = repository;
     _reputationService = reputationService;
     _twitterService = twitterService;
 }
Ejemplo n.º 9
0
        public static async Task Main(string[] args)
        {
            Startup startup = new Startup();
            await startup.InitializeAsync();

            IGenericServiceProvider       serviceProvider = startup.GetServiceProvider();
            IPuzzleService <SudokuPuzzle> puzzleService   = serviceProvider.GetService <IPuzzleService <SudokuPuzzle> >();

            SudokuPuzzle puzzle       = puzzleService.Generate();
            string       beforePuzzle = puzzleService.Print(puzzle);

            Console.WriteLine("Sudoku");
            Console.Write(beforePuzzle);
            Stopwatch      stopwatch      = Stopwatch.StartNew();
            PuzzleSolveDto puzzleSolveDto = puzzleService.Solve(puzzle);

            stopwatch.Stop();

            if (puzzleSolveDto.Success)
            {
                Console.WriteLine($"Solved in: {stopwatch.ElapsedMilliseconds}ms");
                string afterPuzzle = puzzleService.Print(puzzle);
                Console.WriteLine(afterPuzzle);
                ConsoleKeyInfo input;
                do
                {
                    Console.Write("\rPrint all puzzle states? [y/n]\n");
                    input = Console.ReadKey();
                    if (input.KeyChar == 'y')
                    {
                        foreach (PuzzleState state in puzzleSolveDto.PuzzleStates)
                        {
                            Console.Write("\n" + state);
                        }
                        Console.WriteLine();
                        break;
                    }

                    if (!input.KeyChar.Equals('n'))
                    {
                        continue;
                    }
                    Console.WriteLine();
                    break;
                } while (!input.KeyChar.Equals('y') || !input.KeyChar.Equals('n'));
            }
            else
            {
                Console.WriteLine("Failed to solve puzzle!");
            }

            Console.WriteLine("Done. Press any key to quit.");
            Console.ReadKey();
        }
Ejemplo n.º 10
0
        public void CreatePuzzle_ShouldReturnPuzzleResponseObject()
        {
            mockLogger     = new Mock <ILogger <SudokuController> >();
            logger         = mockLogger.Object;
            mockService    = new Mock <IPuzzleService>();
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            repository     = mockRepository.Object;
            sut            = new SudokuController(logger, service, repository);
            var actualResult = sut.CreatePuzzle(0);

            Assert.IsInstanceOfType(actualResult, typeof(ActionResult <PuzzleResponse>));
        }
Ejemplo n.º 11
0
        public PuzzleViewModel(IPuzzleService puzzleService, IEventAggregator eventAggregator)
        {
            // ctr prop
            _puzzleService   = puzzleService;
            _eventAggregator = eventAggregator;

            // event aggregator subscribe - xxx_EA_SUB
            _ = _eventAggregator.GetEvent <ShuffleClickEvent>().Subscribe(ShufflePuzzle_EA_SUB);
            _ = _eventAggregator.GetEvent <ResetClickEvent>().Subscribe(ResetPuzzle_EA_SUB);
            _ = _eventAggregator.GetEvent <ShowSolutionClickEvent>().Subscribe(ShowSolutionPuzzle_EA_SUB);
            _ = _eventAggregator.GetEvent <NavigationClickEvent>().Subscribe(NavigationSettings_EA_SUB);

            // delegate command
            MoveCommand         = new DelegateCommand <object>(Move, CanMove);
            HintMoveCommand     = new DelegateCommand <object>(HintClick, CanHintClick);
            GoBackCommand       = new DelegateCommand(GoBack, CanGoBack);
            GoForwardCommand    = new DelegateCommand(GoForward, CanGoForward);
            IconsWebSiteCommand = new DelegateCommand <object>(IconsWebSite);

            // private
            _cnt                  = 0;
            _moveCnt              = 0;
            _isHint               = false;
            _isPublishMinCount    = false;
            _isShowSearchMesseage = false;
            _isLoadFirst          = false;
            _isGameOver           = false;
            _shuffeldTilesList    = new ObservableCollection <Tile>();
            _solutionNode         = new Node();
            _tempSolutionNode     = new Node();
            _crumb                = 0;
            _breadCrumbsList      = new List <int>();

            // public
            IsBusy       = false;
            IsViewBusy   = false;
            BusyContent  = "";
            MainBoard    = new Board();
            HintTileProp = -1;
            IsSettings   = false;

            // dispatcher timer - solution
            _timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(_timeTick)
            };
            _timer.Tick += Timer_Tick;

            // load solution puzzle async
            LoadPuzzleService();
        }
Ejemplo n.º 12
0
        public void Solution_ShouldReturnPuzzleResponseObject()
        {
            mockLogger  = new Mock <ILogger <SudokuController> >();
            logger      = mockLogger.Object;
            mockService = new Mock <IPuzzleService>();
            mockService.Setup(x => x.GetSolvedSudoku6x6(testData.GetValidPuzzle1()))
            .Returns(testData.GetValidPuzzle1Solution());
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            repository     = mockRepository.Object;
            sut            = new SudokuController(logger, service, repository);
            var actualResult = sut.Solution(new Puzzle(testData.GetValidPuzzle1()));

            Assert.IsInstanceOfType(actualResult, typeof(ActionResult <PuzzleResponse>));
        }
Ejemplo n.º 13
0
        public void CreatePuzzle_ShouldReturnNotNullObject()
        {
            mockLogger     = new Mock <ILogger <SudokuController> >();
            logger         = mockLogger.Object;
            mockService    = new Mock <IPuzzleService>();
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            mockRepository.Setup(x => x.GetPuzzleById(0))
            .Returns(new Puzzle(testData.GetValidPuzzle0()
                                ));
            repository = mockRepository.Object;
            sut        = new SudokuController(logger, service, repository);
            var actualResult = sut.CreatePuzzle(0);

            Assert.IsNotNull(actualResult);
        }
Ejemplo n.º 14
0
        public void CreatePuzzle_ShouldReturnPuzzleForId0()
        {
            mockLogger     = new Mock <ILogger <SudokuController> >();
            logger         = mockLogger.Object;
            mockService    = new Mock <IPuzzleService>();
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            mockRepository.Setup(x => x.GetPuzzleById(0))
            .Returns(new Puzzle(testData.GetValidPuzzle0()
                                ));
            repository = mockRepository.Object;
            sut        = new SudokuController(logger, service, repository);
            var actualResult   = sut.CreatePuzzle(0);
            var expectedResult = new PuzzleResponse(Constants.Code.OK, Constants.Message.Success, testData.GetValidPuzzle0());

            Assert.AreEqual(expectedResult.Equals(actualResult.Value), true);
        }
Ejemplo n.º 15
0
        public void Solution_ShouldReturnNoSolutionForInvalidPuzzle()
        {
            mockLogger = new Mock <ILogger <SudokuController> >();
            logger     = mockLogger.Object;
            var puzzle = testData.GetInvalidPuzzle();

            mockService = new Mock <IPuzzleService>();
            mockService.Setup(x => x.GetSolvedSudoku6x6(puzzle))
            .Returns((int[][])null);
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            repository     = mockRepository.Object;
            sut            = new SudokuController(logger, service, repository);
            var actualResult   = sut.Solution(new Puzzle(puzzle));
            var expectedResult = new PuzzleResponse(Constants.Code.OK, Constants.Message.SolutionNotFound, null);

            Assert.AreEqual(expectedResult.Equals(actualResult.Value), true);
        }
Ejemplo n.º 16
0
 public SidebarController(IPuzzleService puzzleService, IAccountService accountService)
 {
     _puzzleService = puzzleService;
     _accountService = accountService;
 }
Ejemplo n.º 17
0
 public ProblemController(IPuzzleService puzzleService, FreshBoardDbContext dbContext)
 {
     _puzzleService = puzzleService;
     _dbContext     = dbContext;
 }
Ejemplo n.º 18
0
 public SudokuController(ILogger <SudokuController> logger, IPuzzleService service, IPuzzleRepository repository)
 {
     _logger           = logger;
     _sudokuService    = service;
     _puzzlerepository = repository;
 }
Ejemplo n.º 19
0
 public HomeController(IPuzzleService _IPuzzleService)
 {
     this.IPuzzleService = _IPuzzleService;
 }
Ejemplo n.º 20
0
 public HomeController(IPuzzleService puzzleService, IAuthenticationService authenticationService, IAccountService accountService)
 {
     _puzzleService = puzzleService;
     _authenticationService = authenticationService;
     _accountService = accountService;
 }
Ejemplo n.º 21
0
 public AdminController(IPuzzleService _IPuzzleService)
 {
     this.IPuzzleService = _IPuzzleService;
 }
Ejemplo n.º 22
0
 public PuzzlesController(IPuzzleService puzzleService)
 {
     _puzzleService = puzzleService;
 }
Ejemplo n.º 23
0
        public PuzzleViewModel(INavigationService navigationService, IPuzzleService puzzleService) : base(navigationService)
        {
            Title = "Number finder";

            puzzle = puzzleService;
        }
Ejemplo n.º 24
0
 public PartService(PuzzleStoreDbContext db,
                    IPuzzleService puzzles,
                    IAdminUserService users)
 {
     this.db = db;
 }
Ejemplo n.º 25
0
 public PuzzleController(IPuzzleService puzzleService, UserManager <FreshBoardUser> userManager)
 {
     _puzzleService = puzzleService;
     _userManager   = userManager;
 }