コード例 #1
0
        public void UpdateTranslate_should_update_translate()
        {
            var dto        = TranslateFakeData.GetFakedUpdatedTranslate();
            var translate  = Substitute.For <Translator>();
            var repository = Substitute.For <ITranslationRepository>();

            repository.GetById(dto.Id).Returns(translate);

            var sut = new TranslationService(repository);

            sut.ModifyTranslate(dto);

            var language     = new LanguageBuilder().WithAbbrevation(dto.LanguageAbbr).Build();
            var phraseType   = new PhraseTypeBuilder().WithName(dto.PhraseType).Build();
            var phrase       = new PhraseBuilder().WithId(dto.PhraseId).WithPhraseType(phraseType).Build();
            var translations = new List <Domain.Entities.Translation>()
            {
                new Domain.Entities.Translation(language, dto.Translation)
            };
            var expectedTranslate = new TranslateBuilder()
                                    .WithId(dto.Id)
                                    .WithPhrase(phrase)
                                    .WithTranslations(translations).Build();

            translate.Received().Update(phrase, translations);
        }
コード例 #2
0
        public void Repository_should_save_translate()
        {
            var repository = new TranslationRepository(DbContext);

            var phraseType   = new PhraseType(7, "commodity", "کالا");
            var phrase       = new Phrase(15, "گندم", phraseType);
            var language     = new Language(1, "انگلیسی", "English", "EN");
            var translations = new List <Domain.Entities.Translation>()
            {
                new Domain.Entities.Translation(0, language, "Wheat")
            };
            var translatedPhrase = new TranslateBuilder()
                                   .WithPhrase(phrase)
                                   .WithTranslations(translations).Build();

            repository.Save(translatedPhrase);

            var id = translatedPhrase.Id;

            DbContext.ClearChangeTracker();


            var result = repository.GetById(id);

            Assert.Equal(result, translatedPhrase, new TranslatorEqualityComparer());
        }
コード例 #3
0
        public ITranslator <TSchema> Create(TranslateFactoryContext <TSchema> context)
        {
            var builder = new TranslateBuilder <TSchema>(context);

            _specification.Apply(builder);

            return(builder.Build());
        }
コード例 #4
0
        protected override async Task Do()
        {
            TranslateBuilder.NO_CACHE = NoCache;

            var builder = new TranslateBuilder(NotabenoidLogin, NotabenoidPassword, BookId, GameDir, TranslateDir);

            if (Res != null)
            {
                await builder.Build(Res);
            }
            else
            {
                await builder.Build();
            }
        }
コード例 #5
0
        public void CreateTranslate_should_save_translate()
        {
            var dto        = TranslateFakeData.GetFakedCreatedTranslate();
            var repository = Substitute.For <ITranslationRepository>();
            var sut        = new TranslationService(repository);

            sut.CreateTranslate(dto);

            var language     = new LanguageBuilder().WithAbbrevation(dto.LanguageAbbr).Build();
            var translations = new List <Domain.Entities.Translation>()
            {
                new Domain.Entities.Translation(language, dto.Translation)
            };

            var phraseType        = new PhraseTypeBuilder().WithName(dto.PhraseType).Build();
            var phrase            = new PhraseBuilder().WithId(dto.PhraseId).WithPhraseType(phraseType).Build();
            var expectedTranslate = new TranslateBuilder()
                                    .WithPhrase(phrase)
                                    .WithTranslations(translations).Build();

            repository.Received(1).Save(ArgExt.Compare(expectedTranslate, new TranslatorEqualityComparer()));
        }
コード例 #6
0
 public TranslatorTests()
 {
     _sutBuilder = new TranslateBuilder();
 }