Пример #1
0
        public void RetrieveAllWords_WhenGiveAFilePath_ShouldCallFileWrapperWithSameString()
        {
            var moqFileWrapper = new Mock<IFileWrapper>();

            moqFileWrapper.Setup(m => m.ReadFile(It.IsAny<string>())).Returns(new List<string>());

            var target = new WordService(moqFileWrapper.Object);

            target.RetrieveAllWordsToConsole(string.Empty);

            moqFileWrapper.Verify(m => m.ReadFile(It.IsAny<string>()), Times.Once);
        }
Пример #2
0
        public void AddWord_WhenGivenAString_ShouldCallFileWrapperWithSameStringOnce()
        {
          

            var moqFileWrapper = new Mock<IFileWrapper>();

            moqFileWrapper.Setup(m => m.AppendText(It.IsAny<string>(),
                                                   It.IsAny<string>()));

            WordService target = new WordService(moqFileWrapper.Object);

            target.AddWord(string.Empty, string.Empty);

            moqFileWrapper.Verify(m => m.AppendText(It.IsAny<string>(), 
                                                    It.IsAny<string>()), Times.Once);
        }
        public AutomaticallySetTemporaryDefinitions()
        {
            TestFileHelper.Create(Filename);

            var json = TestFileHelper.Read(Filename);

            _webDictionaryRequestHelper = Substitute.For <IWebDictionaryRequestHelper>();
            _wordExistenceHelper        = Substitute.For <IWordExistenceHelper>();
            _wordDefinitionHelper       = Substitute.For <IWordDefinitionHelper>();
            _fileHelper = new FileHelper();

            _filenameHelper = Substitute.For <IFilenameHelper>();
            _filenameHelper.GetGuessedWordsFilename().Returns(Filename);
            _filenameHelper.GetDictionaryFilename().Returns(Filename);

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _dictionary  = _wordService.GetDictionary();
        }
Пример #4
0
        public void WhenWordIsInTheDictionaryThenACallShouldBeMadeToGetTheDefinition()
        {
            var word = "sheep";

            _wordDefinitionHelper.ClearReceivedCalls();

            _wordExistenceHelper
            .DoesWordExist(word)
            .Returns(true);

            _wordDefinitionHelper.GetDefinitionForWord(word).Returns("An absolutely baaing animal");

            var wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            var response    = wordService.GetDefinition(Filename, word);

            _wordDefinitionHelper.Received().GetDefinitionForWord(word);
            response.Should().Be("An absolutely baaing animal");
        }
Пример #5
0
        public async Task WordsTooLong_CallConsoleWriteLine_Once()
        {
            var mockFileProcessor = new Mock <IFileService>();

            mockFileProcessor.Setup(x => x.ReadDictionaryFile(It.IsAny <string>())).ReturnsAsync(new List <string>()
            {
                "pift", "paft", "zoom"
            });
            var mockWriter = new Mock <ITextWriter>();
            var output     = new StringWriter();

            Console.SetOut(output);

            var wordProcessor = new WordService(mockFileProcessor.Object, mockWriter.Object, mockConfigurations.Object);
            await wordProcessor.Run("ararararara", "paft");

            mockWriter.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Once);
        }
Пример #6
0
        public void downloadDictionaryTest()
        {
            Word.setScoringHandler(new ScoringHandler("../../ScoringHandlerDaoTests.xml"));
            string      file = "../../addDictionaryFromWebTest.txt";
            List <Word> expeected;
            List <Word> result;

            wc.addDictionaryFromFile(language, file);
            expeected = WordService.getInstance().getAll(language, 100);
            foreach (Word w in expeected)
            {
                Console.WriteLine(w.Content);
            }
            DatabaseController.getInstance().removeTable(language.ToString());
            wc.downloadDictionary(language, "http://www.mieliestronk.com/corncob_lowercase.txt");
            result = WordService.getInstance().getAll(language, 100);
            CollectionAssert.AreEquivalent(expeected, result);
        }
Пример #7
0
        public void FillFileAndSave()
        {
            // TODO : Fill base
            //DataBaseTransport.AddSupplierOrder(entryOrder);

            GetInfoFromDB();

            var word = new WordService(wherePath + "\\" + FILE_NAME, false);

            word.FindReplace("[fromDate]", entryOrder.fromDate);
            //word.FindReplace("[brokerClient]", entryOrder.brokerClient);
            //word.FindReplace("[brokerClient]", entryOrder.brokerClient);
            word.FindReplace("[lotNumber]", entryOrder.lotNumber);
            word.FindReplace("[memberCode]", entryOrder.memberCode);
            word.FindReplace("[fullMemberName]", entryOrder.fullMemberName);
            word.FindReplace("[clientCode]", entryOrder.clientCode);
            word.FindReplace("[clientFullName]", entryOrder.clientFullName);
            word.FindReplace("[clientAddress]", entryOrder.clientAddress);
            word.FindReplace("[clientBIN]", entryOrder.clientBIN);
            word.FindReplace("[clientPhones]", entryOrder.clientPhones);
            word.FindReplace("[clientBankIIK]", entryOrder.clientBankIIK);
            word.FindReplace("[clientBankBIK]", entryOrder.clientBankBIK);
            word.FindReplace("[clientBankName]", entryOrder.clientBankName);

            var stringBuilder = new StringBuilder();

            stringBuilder.Append("Список запрашиваемых документов").Append("\n");
            stringBuilder.Append("1. Заявка на участие").Append("\n");

            var iCount = 2;

            foreach (var rDoc in entryOrder.requestedDocs)
            {
                stringBuilder.Append(iCount + ". " + rDoc.name).Append("\n");
                iCount++;
            }

            word.SetCell(2, 3, 2, stringBuilder.ToString());

            word.CloseDocument(true);
            word.CloseWord(true);

            ChangeFileName();
        }
Пример #8
0
        static void Main(string[] args)
        {
            int port = 8888;

            Task <int>[] tasks   = new Task <int> [Environment.ProcessorCount * 2]; // Количество потоков
            var          service = new WordService(new FileStream("test.in", FileMode.Open), port);

            service.RunService();
            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = new Task <int>(() =>
                {
                    var timer = new Stopwatch();
                    int count = 0;
                    try
                    {
                        var factory = new ChannelFactory <IWordContract>(new NetTcpBinding()
                                                                         , new EndpointAddress($"net.tcp://localhost:{port}"));
                        IWordContract client = factory.CreateChannel();
                        timer.Start();
                        foreach (var prefix in service.Prefixes)
                        {
                            client.GetWordsAsync(prefix, 10).GetAwaiter().GetResult();
                            count++;
                            if (count % 1000 == 0)
                            {
                                Log.Write($"Поток {Thread.CurrentThread.ManagedThreadId}: {count / timer.Elapsed.TotalSeconds} запросов/сек");
                            }
                        }
                        timer.Stop();
                    }
                    catch (Exception ex)
                    {
                        Log.WriteError($"{Thread.CurrentThread.ManagedThreadId}: {ex.Message}\r\n{ex.StackTrace}");
                    }
                    return((int)(count / timer.Elapsed.TotalSeconds));
                });
                tasks[i].Start();
                Thread.Sleep(500);
            }
            Task.WhenAll(tasks).Wait(Timeout.Infinite);
            Log.Write($"Всего запросов/сек: {tasks.Select(s => s.Result).Sum()}");
            Console.ReadLine();
        }
Пример #9
0
        public void WhenUserMarksNonExistingWordAsNonExistingThenStatusShouldBeNonExisting()
        {
            var word = "dinosaur";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.ToggleIsWordInDictionary(Filename, word, false);
            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = word,
                TemporaryDefinition = null,
                PermanentDefinition = null,
                Status = WordStatus.DoesNotExist
            });
        }
Пример #10
0
        public ActionResult CreateMeaning(int id, MeaningCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            //if(is null)
            // { return View(model); }

            var serviceMeaning = new MeaningService();
            var serviceWord    = new WordService();
            var word           = serviceWord.GetWordById(id);


            serviceMeaning.CreateMeaning(word, model);
            return(RedirectToAction("Details", "Word", new { id = word.WordId }));
        }
        public static bool FillMembers(string templateFileName, List <SupplierOrder> members)
        {
            if (string.IsNullOrEmpty(templateFileName) || members == null || members.Count < 1)
            {
                return(false);
            }

            var word = new WordService(templateFileName, false);

            if (word == null)
            {
                return(false);
            }

            try {
                int rowCount = 2;

                foreach (var item in members)
                {
                    if (rowCount > 2)
                    {
                        word.AddTableRow(1);
                    }

                    word.SetCell(1, rowCount, 1, (rowCount - 1).ToString());
                    word.SetCell(1, rowCount, 2, item.Name != null ? item.Name : "");
                    word.SetCell(1, rowCount, 3, item.BrokerName != null ? item.BrokerName : "");
                }
            } catch {
                return(false);
            } finally {
                if (word.IsOpenDocument())
                {
                    word.CloseDocument();
                }
                if (word.IsOpenWord())
                {
                    word.CloseWord(false);
                }
            }

            return(true);
        }
    public MainForm()
    {
        InitializeComponent();
        System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\Inzenyria_programowania-ce5078cd8d32.json");
        client               = TranslationClient.Create();
        dataContext          = new DBClassesDataContext();
        languageService      = new LanguageService(dataContext);
        wordService          = new WordService(dataContext);
        translationDBservice = new TranslationDBService(dataContext);
        googleTranslate      = new TranslationAPIService(client);

        titleToShortTitleMap = new Dictionary <String, String>();
        foreach (Google.Cloud.Translation.V2.Language language in client.ListLanguages("en"))
        {
            insertLanguageComboBox.Items.Add(language.Name);
            titleToShortTitleMap.Add(language.Name, language.Code);
        }
        insertLanguageComboBox.SelectedItem = "Polish"; //default
    }
Пример #13
0
        public void WhenUserMarksPermanentWordWithNoDefinitionsAsExistingThenStatusShouldBePermanent()
        {
            var word = "sheep";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.ToggleIsWordInDictionary(Filename, word, true);
            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = word,
                TemporaryDefinition = TestFileHelper.SheepTemporaryDefinition,
                PermanentDefinition = TestFileHelper.SheepPermanentDefinition,
                Status = WordStatus.Permanent
            });
        }
Пример #14
0
        public void WhenUserMarksNonExistingWordWithATemporaryDefinitionButNoPermanentDefinitionAsExistingThenStatusShouldBeTemporary()
        {
            var word = "unicorn";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.ToggleIsWordInDictionary(Filename, word, true);
            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = word,
                TemporaryDefinition = TestFileHelper.UnicornTemporaryDefinition,
                PermanentDefinition = null,
                Status = WordStatus.Temporary
            });
        }
Пример #15
0
        public void CreateTemplate(FormC01 form, string saveTo)
        {
            var FILE_NAME = "formC01.docx";

            System.IO.File.Copy(FileArchiveTransport.GetFormC01TemplateFileName(), saveTo + "\\" + FILE_NAME, true);

            var word = new WordService(saveTo + "\\" + FILE_NAME, false);

            word.SetCell(1, 1, 2, form.broker.name);
            word.SetCell(1, 2, 2, form.broker.code);
            word.SetCell(2, 2, 1, form.code);
            word.SetCell(2, 2, 2, form.bin);
            word.SetCell(2, 2, 3, form.name);
            word.SetCell(2, 2, 5, form.codeG + " " + form.codeS);
            word.SetCell(2, 2, 6, form.codeP);

            word.CloseDocument(true);
            word.CloseWord(true);
        }
        private static void FillApplicantsTable(WordService word, List <SupplierOrder> applicants, int tableNumber)
        {
            int iCount   = 1;
            int rowCount = 2;

            foreach (var item in applicants)
            {
                if (iCount > 2)
                {
                    word.AddTableRow(tableNumber);
                }

                word.SetCell(tableNumber, rowCount, 1, iCount.ToString());
                word.SetCell(tableNumber, rowCount, 2, item.Name != null ? item.Name : "");

                iCount   += 1;
                rowCount += 1;
            }
        }
Пример #17
0
        public async Task <string[]> SetUpDatabase(WordService service)
        {
            //if there are any words in the database, we want to delete them
            Task <List <Word> > getTask = service.GetAllWords();
            List <Word>         getList = await getTask;

            foreach (Word word in getList)
            {
                bool deleted = await service.Delete(word.Id);

                if (!deleted)
                {
                    throw new System.Exception("Item not deleted!");
                }
            }

            //let's always have these two words in the database
            Word word1 = new Word();

            word1.Vernacular = "One";
            word1.Gloss      = 1;
            word1.Audio      = "audio1.mp4";
            word1.Timestamp  = "1:00";

            Word word2 = new Word();

            word2.Vernacular = "Two";
            word2.Gloss      = 2;
            word2.Audio      = "audio2.mp4";
            word2.Timestamp  = "2:00";

            //since the ids will change every time, I'm going to return them for easy reference
            string[] idList = new string[2];
            word1 = await service.Create(word1);

            word2 = await service.Create(word2);

            idList[0] = word1.Id;
            idList[1] = word2.Id;

            return(idList);
        }
Пример #18
0
        public void WhenUserUpdatesExistingDefinition()
        {
            var word          = "pelican";
            var newDefinition = TestFileHelper.PelicanPermanentDefinition;

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.UpdateExistingWord(Filename, word, newDefinition);
            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = word,
                TemporaryDefinition = TestFileHelper.PelicanTemporaryDefinition,
                PermanentDefinition = newDefinition,
                Status = WordStatus.Permanent
            });
        }
Пример #19
0
        public void WhenUserAddsNewWordToDictionary()
        {
            var word          = "hello";
            var newDefinition = "A friendly greeting";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.AddNewWordToDictionary(Filename, word, newDefinition);
            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = word,
                TemporaryDefinition = null,
                PermanentDefinition = newDefinition,
                Status = WordStatus.Permanent
            });
        }
Пример #20
0
        public void GivenADictionaryWhenWordsAreGeneratedTheCountsAreEqual()
        {
            // Arrange
            Dictionary <string, int> words = new Dictionary <string, int>
            {
                { "test", 3 },
                { "string", 5 },
                { "please", 8 }
            };

            // Act
            var service = new WordService();
            var results = service.GenerateWords(words);

            // Assert
            Assert.Equal(3, results.Count);
            Assert.Equal("test", results[0].Word);
            Assert.Equal(3, results[0].Count);
            Assert.True(results[0].Id.Length > 0);
        }
Пример #21
0
        public void WhenAWordFormattedAsPluralDoesNotExistInTheSingularThenWordServiceShouldReturnFalse()
        {
            var word = "notawords";

            _wordExistenceHelper
            .DoesWordExist(word)
            .Returns(false);

            _wordExistenceHelper
            .DoesWordExist(Arg.Any <string>())
            .Returns(false);

            _wordHelper
            .StrippedSuffixDictionaryCheck(Arg.Any <Dictionary>(), word)
            .Returns(false);

            var wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            var response    = wordService.GetWordStatus(Filename, word);

            response.Should().BeFalse();
        }
Пример #22
0
        public void TestReadTable(string fileName)
        {
            Console.WriteLine("测试读取 Word 文件中的表格信息!");

            string fullPathFileName =
                System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
                + @"WordFiles\" + fileName;

            WordService wordService = new WordService();

            wordService.StartWord();
            wordService.OpenWordFile(fullPathFileName);



            wordService.ShowAllTable();


            wordService.CloseWordFile();
            wordService.CloseWordApp();
        }
Пример #23
0
        public void WhenNoDefinitionIsEnteredTheWordShouldStillBeWritten()
        {
            var newWord       = "new";
            var newDefinition = "";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.AddNewWordToDictionary(Filename, newWord, newDefinition);
            _wordService.UpdateDictionaryFile();

            var response = TestFileHelper.Read(Filename);

            var dictionary = JsonConvert.DeserializeObject <Dictionary>(response);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = newWord,
                PermanentDefinition = newDefinition,
                TemporaryDefinition = null,
                Status = WordStatus.Permanent
            });
        }
Пример #24
0
        public void WhenADefinitionIsSetThenItShouldBeWrittenToTheDictionary()
        {
            var newWord       = "new";
            var newDefinition = "Something that has only just come into existence";

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _wordService.AddNewWordToDictionary(Filename, newWord, newDefinition);
            _wordService.UpdateDictionaryFile();

            var response = TestFileHelper.Read(Filename);

            var dictionary = JsonConvert.DeserializeObject <Dictionary>(response);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = newWord,
                PermanentDefinition = newDefinition,
                TemporaryDefinition = null,
                Status = WordStatus.Permanent
            });
        }
Пример #25
0
        private static void FillTemplate(int mode)
        {
            // Open template file for filling
            word = new WordService(fileName, false);

            switch (mode)
            {
            case 1:     // Single
                        // Fill file with data
                word.FindReplace("[brokerName]", order.Auction.SupplierOrders[0].BrokerName);
                word.SetCell(1, 2, 1, order.Auction.SupplierOrders[0].BrokerCode);
                word.SetCell(1, 2, 2, order.Auction.SupplierOrders[0].Code);
                word.SetCell(1, 2, 3, order.Auction.Lots[0].Number);
                word.SetCell(1, 2, 4, (Math.Round(sum, 2)).ToString());
                word.FindReplace("[curDate]", DateTime.Now.ToShortDateString());
                break;

            case 2:     // Multi
                word.FindReplace("[brokerName]", broker);

                int iRow = 2;

                foreach (var item in moneyTransferList)
                {
                    word.SetCell(1, iRow, 1, item.fromCompany);
                    word.SetCell(1, iRow, 2, item.toCompany);
                    word.SetCell(1, iRow, 3, item.lotNumber);
                    word.SetCell(1, iRow, 4, (Math.Round(sum, 2)).ToString());

                    word.AddTableRow(1);
                    iRow++;
                }

                word.FindReplace("[curDate]", DateTime.Now.ToShortDateString());
                break;
            }
            // Close file & save
            word.CloseDocument(true);
            word.CloseWord(true);
        }
Пример #26
0
        public async Task TestGetAllWords()
        {
            //Test with empty database
            WordService service = ServiceBuilder;                //build an empty database

            Task <List <Word> > getTask = service.GetAllWords(); //This is probably how to do async tasks...?
            List <Word>         getList = await getTask;         //get the actual list of items returned by the action

            Assert.AreEqual(getList.Count, 0);                   //empty database should have no entries
            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => getList[0]);
            //indexing into an empty list should throw an exception here

            //Test with populated database
            string[] idList = SetUpDatabase(service).Result;
            //populates the database and gives us the ids of the members

            getTask = service.GetAllWords();
            getList = await getTask;

            Assert.AreEqual(getList.Count, 2); //this time, there should be two entries

            Word wordInDb1 = getList[0];
            Word wordInDb2 = getList[1];

            //let's check that everything is right about them
            Assert.AreEqual(wordInDb1.Id, idList[0]);
            Assert.AreEqual(wordInDb1.Vernacular, "One");
            Assert.AreEqual(wordInDb1.Gloss, 1);
            Assert.AreEqual(wordInDb1.Audio, "audio1.mp4");
            Assert.AreEqual(wordInDb1.Timestamp, "1:00");

            Assert.AreEqual(wordInDb2.Id, idList[1]);
            Assert.AreEqual(wordInDb2.Vernacular, "Two");
            Assert.AreEqual(wordInDb2.Gloss, 2);
            Assert.AreEqual(wordInDb2.Audio, "audio2.mp4");
            Assert.AreEqual(wordInDb2.Timestamp, "2:00");

            //indexing to the third element should throw an exception
            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => getList[2]);
        }
Пример #27
0
        public KanjiListViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
            List <Word> wordList = new WordService().GetWordList();
            ObservableCollection <Word> wordCollection = new ObservableCollection <Word>();

            foreach (Word word in wordList)
            {
                word.BackgroundColor = "#5389d6";
                word.BorderColor     = "#64aeff";
                wordCollection.Add(word);
            }

            Words          = wordCollection;
            CurrentMeaning = "- Nghĩa: " + Words.ElementAt(0).Mean;
            CurrentKunyomi = "- Kunyomi: " + Words.ElementAt(0).Onyomi;
            CurrentOnyomi  = "- Onyomi: " + Words.ElementAt(0).Kunyomi;
            CurrentExample = Words.ElementAt(0).Example;
            CurrentKanji   = Words.ElementAt(0).Kanji;
            Words.ElementAt(0).BackgroundColor = "#ff8410";
            Words.ElementAt(0).BorderColor     = "#ffb479";
        }
Пример #28
0
        public WordStatusTests()
        {
            _filenameHelper = Substitute.For <IFilenameHelper>();
            _filenameHelper
            .GetGuessedWordsFilename()
            .Returns(Filename);

            _filenameHelper
            .GetDictionaryFilename()
            .Returns(Filename);

            TestFileHelper.Create(Filename);
            var json = TestFileHelper.Read(Filename);

            _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>();
            _wordExistenceHelper  = Substitute.For <IWordExistenceHelper>();
            _wordHelper           = Substitute.For <IWordHelper>();
            _fileHelper           = new FileHelper();

            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            _dictionary  = _wordService.GetDictionary();
        }
        public AutomaticallyAddNewWordToDictionaryTests()
        {
            _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>();
            _wordExistenceHelper  = Substitute.For <IWordExistenceHelper>();
            _wordHelper           = Substitute.For <IWordHelper>();
            _filenameHelper       = Substitute.For <IFilenameHelper>();
            _filenameHelper.GetDictionaryFilename().Returns(Filename);
            _filenameHelper.GetGuessedWordsFilename().Returns(Filename);
            _fileHelper = new FileHelper();


            if (File.Exists(Filename))
            {
                File.Delete(Filename);
            }

            TestFileHelper.Create(Filename);
            _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            var json = TestFileHelper.Read(Filename);

            _dictionary = _wordService.GetDictionary();
        }
Пример #30
0
        private void OpenTemplate()
        {
            word = new WordService(fPath + "\\" + FILE_NAME, false);

            word.FindReplace("[brokerName]", moneyTransferList[0].brokerName);

            var iCount = 1;

            foreach (var item in moneyTransferList)
            {
                if (iCount != 1)
                {
                    word.AddTableRow(1);
                }

                word.SetCell(1, iCount + 1, 1, item.fromCompany);
                word.SetCell(1, iCount + 1, 2, item.toCompany);
                word.SetCell(1, iCount + 1, 3, item.lotNumber);
                word.SetCell(1, iCount + 1, 4, item.sum);

                iCount++;
            }
        }
Пример #31
0
        public void WhenWordIsNotInTheDictionaryThenNoCallShouldBeMadeToGetDefinition()
        {
            var word = "sheep";

            _wordDefinitionHelper.ClearReceivedCalls();

            _wordExistenceHelper
            .DoesWordExist(word)
            .Returns(false);

            _wordHelper
            .StrippedSuffixDictionaryCheck(Arg.Any <Dictionary>(), word)
            .Returns(false);

            var wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper);
            var response    = wordService.GetDefinition(Filename, word);

            _wordDefinitionHelper
            .DidNotReceive()
            .GetDefinitionForWord(word);

            response.Should().Be(null);
        }
Пример #32
0
        private static void FillSpecification()
        {
            // Fill specification
            word = new WordService(orderFiles[2], false);

            word.FindReplace("[auctionNumber]", order.Auction.Number);                                               // Auction number

            word.SetCell(1, 2, 1, "1");                                                                              // Number
            word.SetCell(1, 2, 2, order.Auction.Lots[0].Name);                                                       // Name
            word.SetCell(1, 2, 3, order.Auction.Lots[0].Unit);                                                       // Unit of size
            word.SetCell(1, 2, 4, order.Auction.Lots[0].Quantity.ToString());                                        // Quantity
            word.SetCell(1, 2, 5, order.Auction.Lots[0].Price.ToString());                                           // Price
            word.SetCell(1, 2, 6, order.Auction.Lots[0].Sum.ToString());                                             // Sum
            word.SetCell(1, 2, 7, order.Auction.Lots[0].Step.ToString());                                            // Step
            word.SetCell(1, 2, 8, order.Auction.Lots[0].DeliveryPlace + " | " + order.Auction.Lots[0].DeliveryTime); // Terms
            word.SetCell(1, 2, 9, order.Auction.Lots[0].PaymentTerm);                                                // Payment
            word.SetCell(1, 2, 10, order.Auction.Lots[0].Warranty.ToString());                                       // Warranty
            word.SetCell(1, 2, 11, order.Auction.Lots[0].LocalContent.ToString());                                   // Local

            // Close specification
            word.CloseDocument(true);
            word.CloseWord(true);
        }