public ActionResult Display(WordSearchIndexModel wordSearchIndexModel) { // ToDo - this should go in a service IRandomNumberService randomNumberService = new RandomNumberService(); IWordPlacementService wordPlacementService = new WordPlacementService(randomNumberService); var wordSearchGrid = new WordSearchGrid(wordSearchIndexModel.Rows, wordSearchIndexModel.Columns, wordPlacementService, randomNumberService); wordSearchIndexModel.Words .Where(w => !string.IsNullOrEmpty(w)) .ToList() .ForEach(a => wordSearchGrid.AddHiddenWord(a)); wordSearchGrid.FillEmptySpaces(); var wordSearchDisplayModel = new WordSearchDisplayModel(wordSearchIndexModel); var grid = wordSearchGrid.Grid; var hiddenWords = wordSearchGrid.HiddenWords; wordSearchDisplayModel.Grid = grid; wordSearchDisplayModel.HiddenWords = hiddenWords; return(View(wordSearchDisplayModel)); }
public void TestNoofRandomNumbers() { int NoofRandomNumbers = 8; RandomNumberService testService = new RandomNumberService(); var result = testService.RandomGeneratorwithColorCodes(NoofRandomNumbers); Assert.AreEqual(result.RandonNumbers.Count, NoofRandomNumbers); }
public ExpService(RandomNumberService rand, IServiceScopeFactory serviceScopeFactory, ILogger <ExpService> log) { _rand = rand; _serviceScopeFactory = serviceScopeFactory; _log = log; _timer = new Timer(WriteBackCache, null, TimeSpan.FromSeconds(_USER_EXP_WRITEBACK_MIN), TimeSpan.FromSeconds(_USER_EXP_WRITEBACK_MAX)); }
public void TestDistinctRandomNumbers() { int NoofRandomNumners = 6; RandomNumberService testService = new RandomNumberService(); var result = testService.RandomGeneratorwithColorCodes(NoofRandomNumners); int distinctCount = result.RandonNumbers.Distinct().Count(); Assert.AreEqual(distinctCount, NoofRandomNumners); }
public WaifuService( ICacheService cacheService, IWaifuRepository waifuRepo, RandomNumberService rand) { _cacheService = cacheService; _waifuRepo = waifuRepo; _rand = rand; }
public MainWindowViewModel([Named("Random")] INumberService randomService, [Named("Addition")] INumberService additionService) { _randomNumberService = new RandomNumberService(); _additionNumberService = new AdditionNumberService(); GetRandomNumberCommand = ReactiveCommand.Create(() => { Number = _randomNumberService.GetNumber(); }); GetAdditionNumberCommand = ReactiveCommand.Create(() => { Number = _additionNumberService.GetNumber(); }); }
public void PlaceWordInGrid_ValidWordDownwards_Success() { IRandomNumberService randomNumberService = new RandomNumberService(); var wordPlacementService = new WordPlacementService(randomNumberService); var grid = new char[20, 20]; var hiddenWord = new HiddenWord() { Start = new GridLocation(10, 10), Word = "hello", Direction = DirectionFlagsEnum.Down }; var result = wordPlacementService.PlaceWordInGrid(grid, hiddenWord); Assert.True(result); Assert.Equal('h', grid[9, 9]); // grid id 0 based Assert.Equal('e', grid[10, 9]); Assert.Equal('l', grid[11, 9]); Assert.Equal('l', grid[12, 9]); Assert.Equal('o', grid[13, 9]); }
public void SaveRandomNumberTest() { var randomNumber = new GeneratedRandonNumber { Id = 1, GeneratorDateTime = DateTime.UtcNow, RandonNumbers = new List <Models.NumberInfo> { new Models.NumberInfo { Id = 1, Number = 6, ColorCodingId = 1 }, new Models.NumberInfo { Id = 1, Number = 16, ColorCodingId = 2 }, new Models.NumberInfo { Id = 1, Number = 26, ColorCodingId = 3 }, new Models.NumberInfo { Id = 1, Number = 36, ColorCodingId = 4 }, new Models.NumberInfo { Id = 1, Number = 45, ColorCodingId = 5 }, new Models.NumberInfo { Id = 1, Number = 20, ColorCodingId = 3 }, } }; RandomNumberService testService = new RandomNumberService(this.randomNumberRepository); var result = testService.SaveRandomNumber(randomNumber); Assert.AreEqual(result, true); var count = this.randomNumberRepository.GetAllRandomNumbers().Count(); Assert.AreEqual(count, 2); }
private void buttonCreateGrid_Click(object sender, EventArgs e) { IRandomNumberService randomNumberService = new RandomNumberService(); IWordPlacementService wordPlacementService = new WordPlacementService(randomNumberService); var wordSearchGrid = new WordSearchGrid(20, 20, wordPlacementService, randomNumberService); wordSearchGrid.AddHiddenWord("word"); wordSearchGrid.AddHiddenWord("search"); wordSearchGrid.AddHiddenWord("reallylongword"); wordSearchGrid.AddHiddenWord("anotherlongone"); wordSearchGrid.AddHiddenWord("today"); wordSearchGrid.AddHiddenWord("yesterday"); var grid = wordSearchGrid.Grid; var hiddenWords = wordSearchGrid.HiddenWords; var rows = grid.GetUpperBound(0); // 0 based var cols = grid.GetUpperBound(1); // wordSearchGrid.FillEmptySpaces(); labelGrid.Text = wordSearchGrid.ToString(); }
public RandomNumberProviderFilter(RandomNumberService random) { _randomService = random; }
public GamblingModule(ICoinRepository coinRepository, RandomNumberService rand) { _coinRepository = coinRepository; _rand = rand; }
private void setTrueRandomGenerator() { GeneratorIsReady = false; var randService = new RandomNumberService(); var trueRandomGenerator = new TrueRandomGenerator(randService); trueRandomGenerator.Ready += (sender, e) => onGeneratorReady(); trueRandomGenerator.QuotaExceeded += (sender, e) => onGeneratorQuotaExceeded(); trueRandomGenerator.Initialize(); RandomNumberGenerator = trueRandomGenerator; }
public void Setup() { randomSvc = new RandomNumberService(); }
public ChillModule(RandomNumberService randService) { this.randService = randService; }
public void GetWordPlacement() { IRandomNumberService randomNumberService = new RandomNumberService(); var wordPlacementService = new WordPlacementService(randomNumberService); }
static void Main(string[] args) { RandomNumberService randomNumberService; AdditionService additionService; MultiplicationService multiplicationService; #region No Dependency Injection randomNumberService = new RandomNumberService(); additionService = new AdditionService(); multiplicationService = new MultiplicationService(); #endregion #region All Initializations in 1 place //randomNumberService = new RandomNumberService(new ConsoleLogger()); //additionService = new AdditionService(new ConsoleLogger()); //multiplicationService = new MultiplicationService(new ConsoleLogger()); #endregion #region Dependency Injection Basics //var serviceCollection = new ServiceCollection(); //serviceCollection.AddSingleton<ConsoleLogger>(); //var serviceProvider = serviceCollection.BuildServiceProvider(); //randomNumberService = new RandomNumberService(serviceProvider.GetRequiredService<ConsoleLogger>()); //additionService = new AdditionService(serviceProvider.GetRequiredService<ConsoleLogger>()); //multiplicationService = new MultiplicationService(serviceProvider.GetRequiredService<ConsoleLogger>()); #endregion #region FileLogger //var serviceCollection = new ServiceCollection(); //serviceCollection.AddSingleton<ILogger, ConsoleLogger>(); ////serviceCollection.AddSingleton<ILogger>(new FileLogger("output.log")); //var serviceProvider = serviceCollection.BuildServiceProvider(); //randomNumberService = new RandomNumberService(serviceProvider.GetRequiredService<ILogger>()); //additionService = new AdditionService(serviceProvider.GetRequiredService<ILogger>()); //multiplicationService = new MultiplicationService(serviceProvider.GetRequiredService<ILogger>()); #endregion #region Resolving properly //var serviceCollection = new ServiceCollection(); //serviceCollection.AddSingleton<ILogger, ConsoleLogger>(); //serviceCollection.AddSingleton<RandomNumberService>(); //serviceCollection.AddSingleton<AdditionService>(); //serviceCollection.AddSingleton<MultiplicationService>(); //var serviceProvider = serviceCollection.BuildServiceProvider(); //randomNumberService = serviceProvider.GetRequiredService<RandomNumberService>(); //additionService = serviceProvider.GetRequiredService<AdditionService>(); //multiplicationService = serviceProvider.GetRequiredService<MultiplicationService>(); #endregion #region Lifetime management //var serviceCollection = new ServiceCollection(); //serviceCollection.AddTransient<ILogger, ConsoleLogger>(); //serviceCollection.AddSingleton<RandomNumberService>(); //serviceCollection.AddSingleton<AdditionService>(); //serviceCollection.AddSingleton<MultiplicationService>(); //var serviceProvider = serviceCollection.BuildServiceProvider(); //randomNumberService = serviceProvider.GetRequiredService<RandomNumberService>(); //additionService = serviceProvider.GetRequiredService<AdditionService>(); //multiplicationService = serviceProvider.GetRequiredService<MultiplicationService>(); #endregion #region Scrutor //var serviceCollection = new ServiceCollection(); //serviceCollection.AddSingleton<ILogger, ConsoleLogger>(); //serviceCollection.Scan(scan => scan // .FromAssemblyOf<Program>() // .AddClasses(classes => classes.AssignableTo<IService>()) // .AsSelf() // .WithSingletonLifetime()); //var serviceProvider = serviceCollection.BuildServiceProvider(); //randomNumberService = serviceProvider.GetRequiredService<RandomNumberService>(); //additionService = serviceProvider.GetRequiredService<AdditionService>(); //multiplicationService = serviceProvider.GetRequiredService<MultiplicationService>(); #endregion #region Castle Windsor //var serviceCollection = new ServiceCollection(); //serviceCollection.AddSingleton<ILogger, ConsoleLogger>(); //serviceCollection.Scan(scan => scan // .FromAssemblyOf<Program>() // .AddClasses(classes => classes.AssignableTo<IService>()) // .AsSelf() // .WithSingletonLifetime()); //var serviceProvider = WindsorRegistrationHelper.CreateServiceProvider(new WindsorContainer(), serviceCollection); //randomNumberService = serviceProvider.GetRequiredService<RandomNumberService>(); //additionService = serviceProvider.GetRequiredService<AdditionService>(); //multiplicationService = serviceProvider.GetRequiredService<MultiplicationService>(); #endregion var generatedNumbers = randomNumberService.Generate(10); var additionResult = additionService.Add(generatedNumbers); var multiplicationResult = multiplicationService.Multiply(generatedNumbers); Console.WriteLine($"Addition result: {additionResult}"); Console.WriteLine($"Multiplication result: {multiplicationResult}"); }
public DiceModule(RandomNumberService randService, FailMessageService failMessages) { this.randService = randService; this.failMessages = failMessages; }
public IndexModel(RandomNumberService randomNumberService, ILogger <IndexModel> logger) { _randomNumberService = randomNumberService; _logger = logger; }