public void GlossaryRepository_SortGlossaryItems() { Mock <IGlossaryRepository> mock = new Mock <IGlossaryRepository>(); mock.Setup(o => o.Items).Returns(new List <Glossary>() { new Glossary() { Definition = "test1", Term = "Test1" }, new Glossary() { Definition = "test2", Term = "Test2" }, new Glossary() { Definition = "x", Term = "a" } }); GlossaryRepository gr = new GlossaryRepository(); gr.Items = mock.Object.Items; gr.SortList(); Assert.IsTrue(gr.Items.Count == 3); Assert.IsTrue(gr.Items[0].Term == "a"); }
public GlossaryServiceTests() { var config = Setup.GivenConfiguration(); var context = new GlossaryStoreContext(config["FilePath"]); var repo = new GlossaryRepository(context); _service = new GlossaryService(repo); }
public async Task DeleteGlossaryItems() { var subject = new GlossaryRepository(); var result = await subject.GetAllAsync(100); foreach (var item in result.Items) { await subject.DeleteAsync(item.RowKey); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Mock up repository by initial it. // read from a json file. GlossaryRepository repos = new GlossaryRepository(); repos.Initial(); services.AddSingleton <IGlossaryRepository>(repos); }
public async Task QueryGlossaryItems() { var subject = new GlossaryRepository(); var result = await subject.GetAllAsync(100); Assert.AreEqual(100, result.Items.Count()); foreach (var item in result.Items) { Assert.IsNotEmpty(item.Content); } }
public ReadWriteFileController() { string connectionString = Settings.GetStringDB(); _localizationProjectRepository = new LocalizationProjectRepository(connectionString); _localeRepository = new LocaleRepository(connectionString); _translationRepository = new TranslationRepository(connectionString); _translationSubstringRepository = new TranslationSubstringRepository(connectionString); _IXmlNodeExtensions = new IXmlNodeExtensions(connectionString); _glossaryRepository = new GlossaryRepository(connectionString); _partOfSpeechRepository = new PartOfSpeechRepository(connectionString); }
public async Task InsertGlossaryItems() { var subject = new GlossaryRepository(); for (var i = 0; i < 100; i++) { await subject.CreateAsync(new Data.Entity.GlossaryItem { Content = Lorem.Sentence(100), Title = Lorem.Sentence(2) }); } }
private void sveToolStripButton_Click(object sender, EventArgs e) { try { _bindingGlossary.EndEdit(); GlossaryRepository service = new GlossaryRepository(); service.SaveGlossary(_bindingGlossary.DataMember); } catch (Exception exception) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Warn(exception.Message); MessageBox.Show("Произошла ошибка. Приложение будет закрыто.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = DialogResult.Abort; this.Close(); } }
public void Initialize(Guid id) { var connectionString = Settings.GetStringDB(); //TOD нужно передавать глассарий //glossaryId = Guid.Parse("e5f51aa3-8c6b-478f-a277-5497f608eba6"); glossaryId = id; gsr = new GlossariesRepository(connectionString); IEnumerable <Glossaries> gList = gsr.GetGlossaryForEditAsync(glossaryId).Result; List <Glossaries> tt = gList.ToList(); glossaries = tt[0]; //TODO нужно обработать создание нового глоссария, если текущего нет tWriter = new TranslationWriter(_localDefault); glossaryRep = new GlossaryRepository(connectionString); // }
public void Initialize(Guid id) { var connectionString = Settings.GetStringDB(); //TOD нужно передавать глассарий //memoryId = Guid.Parse("47faa0d8-56da-4e09-b151-ded06b587338"); memoryId = id; gsr = new TranslationMemoryRepository(connectionString); IEnumerable <TranslationMemory> gList = gsr.GetForEditAsync(memoryId).Result; List <TranslationMemory> tt = gList.ToList(); memory = tt[0]; //TODO нужно обработать создание нового глоссария, если текущего нет glossaryRep = new GlossaryRepository(connectionString); tWriter = new TranslationWriter(_localDefault); ts = new TranslationSubstringRepository(connectionString); }
public void GlossaryRepository_DeleteGlossaryItem() { Mock <IGlossaryRepository> mock = new Mock <IGlossaryRepository>(); var item = new Glossary() { Definition = "test3", Term = "Test3" }; mock.Setup(o => o.Items).Returns(new List <Glossary>() { new Glossary() { Definition = "test1", Term = "Test1" }, item }); GlossaryRepository gr = new GlossaryRepository(); gr.Items = mock.Object.Items; Assert.IsTrue(gr.Items.Count == 2); gr.Delete(item); Assert.IsTrue(gr.Items.Count == 1); }
public GlossaryController(GlossaryRepository glossaryRepository) { _glossaryRepository = glossaryRepository; }