Пример #1
0
 private void Start()
 {
     CardState.LockCard = false;
     translation        = GetComponentInChildren <TranslationController>();
     rotation           = GetComponentInChildren <RotationController>();
     scale = GetComponentInChildren <ScaleController>();
 }
 private void Window_Initialized(object sender, EventArgs e)
 {
     _keysWindow = new APIKeysWindow();
     ApiKeyController      inputHandler          = new ApiKeyController(_keysWindow);
     YandexAPIInteractor   interactor            = new YandexAPIInteractor();
     TranslationController translationController = new TranslationController(this, interactor, inputHandler);
 }
Пример #3
0
        // In this simple test we check if the number
        // of the segments in the database is incremented
        // when we add try to add a line

        public void TestAddLine()
        {
            //Arrange
            var segment = new SegmentViewModel
            {
                Line1          = "Dummy",
                Line2          = "Dummy",
                Original1      = "Dummy",
                Original2      = "Dummy",
                TranslationID  = 1,
                TimestampEnd   = "00:06:30,000",
                TimestampStart = "00:06:10,000",
            };
            var mockUnitOfWork = new MockUnitOfWork();

            for (int i = 0; i < 3; i++)
            {
                var reposegment = new TranslationSegment();
                mockUnitOfWork.TranslationSegmentRepository.Insert(reposegment);
            }
            ;


            var controller  = new TranslationController(mockUnitOfWork);
            int countbefore = mockUnitOfWork.TranslationSegmentRepository.Get().ToList().Count;
            // Act
            var result = controller.AddLine(segment);

            // Assert
            Assert.IsTrue(mockUnitOfWork.TranslationSegmentRepository.Get().ToList().Count == countbefore + 1);
        }
Пример #4
0
        // A test to see if the right Exeptions are thrown
        // in the CommentIndex method of the Translation controller.
        public void TestCommentIndexTrowsErrors()
        {
            var mockUnitOfWork = new MockUnitOfWork();
            var controller     = new TranslationController(mockUnitOfWork);

            // Act
            // The DataNotFoundExeption should be thrown
            // if the parameter does not match any id
            // in the database.
            try
            {
                var result = controller.CommentIndex(8);
            }
            // Assert
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(DataNotFoundException));
            }
            // Act
            // The MissingParameterExeption should be thrown
            // if the method takes null as a parameter.
            try
            {
                int?variable = null;
                var result   = controller.CommentIndex(variable);
            }
            // Assert
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(MissingParameterException));
            }
        }
Пример #5
0
        // A test to see if the right Exeptions are thrown
        // in the CreateTranslation method of the Translation controller.
        public void TestCreateTranslationThrowsErrors()
        {
            //Arrange
            var mockUnitOfWork = new MockUnitOfWork();
            var controller     = new TranslationController(mockUnitOfWork);

            // Act
            // The DataNotFoundExeption should be thrown
            // if the first parameter does not match any id
            // in the database.
            try
            {
                var result = controller.CreateTranslation(1, null);
            }
            // Assert
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(DataNotFoundException));
            }
            // Act
            // The MissingParameterExeption should be thrown
            // if the method takes null as the first parameter.
            try
            {
                var result = controller.CreateTranslation(null, null);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(MissingParameterException));
            }
        }
    /*****************************************************
    * DECREASE TRANSLATION AMPLIFICATION
    *
    * INFO:    Permet de réduire la valeur qui amplifie
    *          la translation d'un objet et mettre a jour
    *          le label. Non concus pour la manipulation libre.
    *          L'amplification doit avoir un minimum de 1.
    *
    *****************************************************/
    public void DecreaseTranslationAmplification()
    {
        TextMeshPro amplifyLabel = GameObject.FindWithTag("AmplifyTranslationLabel").GetComponent <TextMeshPro>();

        if (amplifyTranslation > 1f && amplifyLabel != null)
        {
            amplifyTranslation -= incrTranslation;
            amplifyLabel.text   = amplifyTranslation.ToString();
            TranslationController.GetInstance().SetTranslationAmplification(amplifyTranslation);
        }
    }
 void Start()
 {
     if (translationController == null)
     {
         translationController = GameObject.Find("TranslationController")
                                 .GetComponent <TranslationController>();          // soo wrong but whatever
     }
     translationController.AddTranslationManager(this);
     textField = GetComponent <Text>();
     UpdateMyText();
 }
        private static TranslationController SetUp(
            Mock <ITranslationService> service             = null,
            Mock <ILogger <TranslationController> > logger = null)
        {
            service = service ?? new Mock <ITranslationService>();
            logger  = logger ?? new Mock <ILogger <TranslationController> >();

            var controller = new TranslationController(logger.Object, service.Object);

            return(controller);
        }
Пример #9
0
        private void BtnImport_Click(object sender, RibbonControlEventArgs e)
        {
            Excel._Worksheet worksheet = Globals.ThisAddIn.excelApplication.ActiveSheet;
            Excel.Range      oRange    = worksheet.UsedRange;
            oRange.ClearContents();
            string                moduleId              = ExcelHelper.GetObjectIdFromText(dynamicMenuModules);
            IHttpRequest          httpRequest           = GlobalMembers.InstanceGlobalMembers.Container.Resolve <IHttpRequest>();
            ITranslationService   _translationService   = GlobalMembers.InstanceGlobalMembers.Container.Resolve <ITranslationService>(new TypedParameter(typeof(IHttpRequest), httpRequest));
            TranslationController translationController = new TranslationController(_translationService);

            ExcelHelper.PopulateTranslationFields(worksheet, moduleId, translationController);
        }
Пример #10
0
 // Start is called before the first frame update
 void Start()
 {
     S = this;
     if (lineRenderer == null)
     {
         Destroy(this);
         Debug.LogError("lineRenderer not set!");
         return;
     }
     waypoints = new List <Vector3>();
     clearPath();
 }
Пример #11
0
 /*****************************************************
 * AWAKE
 *
 * INFO:    Instance de la classe.
 *
 *****************************************************/
 private void Awake()
 {
     //Initialise l'instance de cette classe
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
    // Use this for initialization
    void Awake()
    {
        instance        = this;
        languageStrings = new Dictionary <string, string>();

        if (PlayerPrefs.GetInt("language") == 0)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                SetActualLanguage(Language.eng);
            }
            else
            {
                if (Application.systemLanguage == SystemLanguage.Portuguese)
                {
                    SetActualLanguage(Language.ptbr);
                }
                else if (Application.systemLanguage == SystemLanguage.Russian)
                {
                    SetActualLanguage(Language.ru);
                }
                else if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
                {
                    SetActualLanguage(Language.cn);
                }
                else if (Application.systemLanguage == SystemLanguage.Arabic)
                {
                    SetActualLanguage(Language.ar);
                }
                else if (Application.systemLanguage == SystemLanguage.Japanese)
                {
                    SetActualLanguage(Language.jp);
                }
                else if (Application.systemLanguage == SystemLanguage.Spanish)
                {
                    SetActualLanguage(Language.es);
                }
                else if (Application.systemLanguage == SystemLanguage.Korean)
                {
                    SetActualLanguage(Language.sk);
                }
                else
                {
                    SetActualLanguage(Language.eng);
                }
            }
        }
        else
        {
            int lang = PlayerPrefs.GetInt("language");
            SetActualLanguage((Language)lang);
        }
    }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     S = this;
     if (lineRenderer == null)
     {
         Destroy(this);
         Debug.LogError("lineRenderer not set!");
         return;
     }
     waypoints = new List <Vector3>();
     clearPath();
     recordingIndicator.SetActive(false);
 }
Пример #14
0
        public void GetTranslation_WhenLanguageCodeAndKeyIsPassed_ShouldReturnExpectedValue(LanguageCode languageCode, string key, string expectedResult)
        {
            // Arrange
            var controller = new TranslationController(_translationHelper, _dbContext);

            // Act
            var response = controller.GetTranslation(key, languageCode) as ObjectResult;

            // Assert
            response.Should().NotBeNull();
            response.Should().BeOfType <OkObjectResult>();
            response.StatusCode.Should().Be((int)HttpStatusCode.OK);
            response.Value.Should().Be(expectedResult);
        }
Пример #15
0
        public void Init()
        {
            var tranlations = new List <Translation>
            {
                new Translation {
                    LanguageCode = "LOO1", Phrase = "PHRASE ONE", TranslatedText = "PHRASE TRANSLATED ONE", TranslationID = 0
                },
                new Translation {
                    LanguageCode = "L002", Phrase = "PHRASE TWO", TranslatedText = "PHRASE TRANSLATED TWO", TranslationID = 1
                }
            };

            var translationservice = new Mock <ITranslationService>();

            _translationController = new TranslationController(translationservice.Object);
        }
Пример #16
0
            public static bool Prefix(TranslationController __instance, TextAsset PAPBPGICHCK)
            {
                string name = PAPBPGICHCK.name;

                BetterLanguagesPlugin.log.LogInfo("Set language to " + name);
                LanguageManager.SetLanguage(name);

                // Setting the SaveManager's last language to a one that would work in any cases.
                SaveManager.LastLanguage   = 0;
                __instance.CurrentLanguage = new LanguageUnit(__instance.Languages[0], __instance.Images[0].Images);

                for (int i = 0; i < __instance.ActiveTexts.Count; i++)
                {
                    __instance.ActiveTexts[i].ResetText();
                }
                return(false);
            }
Пример #17
0
    public void Start()
    {
        foreach (Ingredient ingredient in allIngredients)
        {
            string translatedName = ingredient.name.ToString();
            TranslationController.Translate(translatedName, language, ingredient.OnGetTranslation);

            if (ingredient.isAdditionalIngredient)
            {
                additionalIngredients.Add(ingredient);
            }
        }

        TranslationController.Translate("and", language, SetAndString);
        TranslationController.Translate("with", language, SetWithString);

        andString  = "y";
        withString = "con";
    }
Пример #18
0
        // here we make a dummy translation with 53
        // segments max 50 segments are displayed at
        // a time on the site( 50 on every page)
        // the second page should include 3 segments
        public void TestTranslationIndex()
        {
            //Arrange

            var translation = new Translation
            {
                ID         = 1,
                MediaID    = 2,
                LanguageID = 3,
                Media      = new Media {
                    Title = "Dummy"
                },
                Language = new Language {
                    Name = "Dummy2"
                },
                TranslationSegments = new List <TranslationSegment>()
            };

            for (int i = 1; i < 54; i++)
            {
                var segment = new TranslationSegment
                {
                    SegmentID   = i,
                    Translation = translation
                };
                translation.TranslationSegments.Add(segment);
            }
            var mockUnitOfWork = new MockUnitOfWork();

            mockUnitOfWork.TranslationRepository.Insert(translation);
            var controller = new TranslationController(mockUnitOfWork);

            //Act
            var result = controller.Index(1, 2);

            // Assert
            var viewResult = (ViewResult)result;
            PagedList <TranslationSegment> model = viewResult.Model as PagedList <TranslationSegment>;

            Assert.IsTrue(model.Count == 3);
        }
Пример #19
0
 /// <summary>
 /// An implementation of <see cref="TranslationController.GetString(StringNames, Il2CppReferenceArray{Il2CppSystem.Object})"/> that handles IL2CPP casting (do not use on plugin load).
 /// </summary>
 /// <param name="translationController">An instance of <see cref="TranslationController"/></param>
 /// <param name="str">String name to retrieve</param>
 /// <param name="parts">Elements to pass for formatting</param>
 /// <returns>The translated value of <paramref name="str"/> or "STRMISS" when untranslated or when an instance of <see cref="TranslationController"/> does not exist or does not have an instance of <see cref="LanguageUnit"/> assigned to <see cref="TranslationController.CurrentLanguage"/> or <see cref="TranslationController.FallbackLanguage"/>.</returns>
 public static string GetString(this TranslationController translationController, StringNames str, params object[] parts)
 {
     return(translationController != null && (translationController.CurrentLanguage != null || translationController.FallbackLanguage != null) ? translationController.GetString(str, parts.Select(p => (Il2CppSystem.Object)p).ToArray()) : "STRMISS");
 }
Пример #20
0
 public static string GetString(this TranslationController t, StringNames key, params Il2CppSystem.Object[] parts)
 {
     return(t.GetString(key, parts));
 }
Пример #21
0
        /// <summary>
        /// An implementation of <see cref="TranslationController.GetStringWithDefault(StringNames, string, Il2CppReferenceArray{Il2CppSystem.Object})"/> that handles IL2CPP casting and default value when a translation does not exist.
        /// </summary>
        /// <param name="translationController">An instance of <see cref="TranslationController"/></param>
        /// <param name="str">String name to retrieve</param>
        /// <param name="defaultStr">Default string when translation is missing</param>
        /// <param name="parts">Elements to pass for formatting</param>
        /// <returns>The translated value of <paramref name="str"/> or <paramref name="defaultStr"/> when untranslated or when an instance of <see cref="TranslationController"/> does not exist or does not have an instance of <see cref="LanguageUnit"/> assigned to <see cref="TranslationController.CurrentLanguage"/> or <see cref="TranslationController.FallbackLanguage"/>.</returns>
        public static string GetStringWithDefault(this TranslationController translationController, StringNames str, string defaultStr, params object[] parts)
        {
            string text = translationController.GetString(str, parts);

            return /*str == StringNames.NoTranslation &&*/ (text.Equals("STRMISS", StringComparison.Ordinal) && !string.IsNullOrEmpty(defaultStr) ? string.Format(defaultStr, parts) : text);
        }
Пример #22
0
 private void Awake()
 {
     controller = GetComponent <TranslationController>();
 }
 /*****************************************************
 * RESET OBJECT POSITION
 *
 * INFO:    Remet l'objet a sa position initiale.
 *
 *****************************************************/
 public void ResetObjectPosition()
 {
     TranslationController.GetInstance().ResetObjectPosition();
 }
        public void TestPostLanguageToLanguage()
        {
            //init
            var mockJobs         = new Mock <DbSet <Job> >();
            var mockServiceUsers = new Mock <DbSet <ServiceUser> >();
            var mockContext      = new Mock <RoboBrailleDataContext>();

            // arrange
            var users = new List <ServiceUser> {
                new ServiceUser
                {
                    EmailAddress = "*****@*****.**",
                    UserId       = Guid.Parse("d2b97532-e8c5-e411-8270-f0def103cfd0"),
                    ApiKey       = Encoding.UTF8.GetBytes("7b76ae41-def3-e411-8030-0c8bfd2336cd"),
                    FromDate     = new DateTime(2015, 1, 1),
                    ToDate       = new DateTime(2020, 1, 1),
                    UserName     = "******",
                    Jobs         = null
                }
            }.AsQueryable();

            TranslationJob trj = new TranslationJob()
            {
                Id              = Guid.NewGuid(),
                FileContent     = Encoding.UTF8.GetBytes("This is the first translation job."),
                UserId          = Guid.Parse("d2b97532-e8c5-e411-8270-f0def103cfd0"),
                FileExtension   = "txt",
                FileName        = "test",
                MimeType        = "text/plain",
                Status          = JobStatus.Started,
                SubmitTime      = DateTime.Now,
                DownloadCounter = 0,
                InputFileHash   = new byte[8],
                SourceLanguage  = Language.enGB.ToString(),
                TargetLanguage  = Language.daDK.ToString()
            };
            TranslationJob trj2 = new TranslationJob()
            {
                Id              = Guid.NewGuid(),
                FileContent     = Encoding.UTF8.GetBytes("This is the second translation job."),
                UserId          = Guid.Parse("d2b87532-e8c5-e411-8270-f0def103cfd0"),
                FileExtension   = "txt",
                FileName        = "test2",
                MimeType        = "text/plain",
                Status          = JobStatus.Done,
                SubmitTime      = DateTime.Now,
                DownloadCounter = 2,
                InputFileHash   = new byte[2],
                SourceLanguage  = Language.enGB.ToString(),
                TargetLanguage  = Language.svSE.ToString()
            };
            var jobs = new List <TranslationJob> {
                trj2
            }.AsQueryable();

            mockJobs.As <IDbAsyncEnumerable <Job> >().Setup(m => m.GetAsyncEnumerator()).Returns(new TestDbAsyncEnumerator <Job>(jobs.GetEnumerator()));
            mockJobs.As <IQueryable <Job> >().Setup(m => m.Provider).Returns(new TestDbAsyncQueryProvider <Job>(jobs.Provider));

            mockJobs.As <IQueryable <Job> >().Setup(m => m.Expression).Returns(jobs.Expression);
            mockJobs.As <IQueryable <Job> >().Setup(m => m.ElementType).Returns(jobs.ElementType);
            mockJobs.As <IQueryable <Job> >().Setup(m => m.GetEnumerator()).Returns(jobs.GetEnumerator());

            mockServiceUsers.As <IDbAsyncEnumerable <ServiceUser> >().Setup(m => m.GetAsyncEnumerator()).Returns(new TestDbAsyncEnumerator <ServiceUser>(users.GetEnumerator()));
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.Provider).Returns(new TestDbAsyncQueryProvider <ServiceUser>(users.Provider));
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.Expression).Returns(users.Expression);
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.ElementType).Returns(users.ElementType);
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.GetEnumerator()).Returns(users.GetEnumerator());

            mockContext.Setup(m => m.Jobs).Returns(mockJobs.Object);
            mockContext.Setup(m => m.ServiceUsers).Returns(mockServiceUsers.Object);

            var repo    = new TranslationRepository(mockContext.Object);
            var request = new HttpRequestMessage();

            request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Authorization", "Hawk id=\"d2b97532-e8c5-e411-8270-f0def103cfd0\", ts=\"1470657024\", nonce=\"VkcMGB\", mac=\"hXW+BLRoqwlUaQZQtpPToOWnVAh5KbAXGGT5f8dLMVk=\"");
            var serviceController = new TranslationController(repo);

            serviceController.Request = request;
            //call
            var jobid = serviceController.Post(trj).Result;

            //test
            mockJobs.Verify(m => m.Add(It.IsAny <Job>()), Times.Once());

            mockContext.Verify(m => m.SaveChanges(), Times.Exactly(1));
            //twice if it is synced
            //mockContext.Verify(m => m.SaveChanges(), Times.Exactly(2));
        }