public async Task GetSimilarWordsAsync_ResponseTest(string input, int maxDistance, int maxAmount, string[] results)
        {
            // Arrange
            ISpellCheckerService service = CreateSpellCheckerService(
                out Mock <IDataSource> mockDataSource);

            // Act
            IEnumerable <string> actual = await service.GetSimilarWordsAsync(input, maxDistance, maxAmount);

            // Assert
            actual.Should()
            .Equal(results);
        }
        public void Distance_MeasureDistance(string input, string data, double distance)
        {
            // arrange
            ISpellCheckerService service = CreateSpellCheckerService(
                out Mock <IDataSource> mockDataSource);

            // Act
            double actual = service.Distance(input, data);

            // Assert
            Assert.Equal(distance, actual);
            mockDataSource.Verify(x => x.ExistsAsync(It.IsAny <string>()), Times.Never);
            mockDataSource.Verify(x => x.GetAllAsync(), Times.Never);
        }
Beispiel #3
0
 public SearchService(IBrandService brandService,
                      IProductService productService,
                      IRepository <SearchTerm> searchTermRepository,
                      IRepository <CustomDictionary> customDictionaryRepository,
                      ISpellCheckerService spellCheckerService,
                      ILogBuilder logBuilder)
 {
     _brandService               = brandService;
     _searchTermRepository       = searchTermRepository;
     _customDictionaryRepository = customDictionaryRepository;
     _productService             = productService;
     _spellCheckerService        = spellCheckerService;
     _logger = logBuilder.CreateLogger(GetType().FullName);
 }
        public void Distance_IDataSource_IsNull_ExpectException()
        {
            // Arrange
            ISpellCheckerService service = CreateSpellCheckerService(
                out Mock <IDataSource> mockDataSource);

            service._dataSource = null;

            // Act
            // Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                service.Distance(It.IsAny <string>(), It.IsAny <string>());
            });
        }
        public async Task GetSimilarWordsForceAsync_IDataSource_IsNull_ExpectException()
        {
            // Arrange
            ISpellCheckerService service = CreateSpellCheckerService(
                out Mock <IDataSource> mockDataSource);

            service._dataSource = null;

            // Act
            async Task Act() => await service.GetSimilarWordsForceAsync(
                It.IsAny <string>(),
                It.IsAny <double>(),
                It.IsAny <int>());

            // Assert
            await Assert.ThrowsAsync <InvalidOperationException>(Act);
        }
Beispiel #6
0
 public StringPatternFactory(ISpellCheckerService spellCheckerService)
 {
     this.spellCheckerService = spellCheckerService;
 }