Ejemplo n.º 1
0
        public void GetInfo(string tmPath)
        {
            #region "open"
            FileBasedTranslationMemory tm = new FileBasedTranslationMemory(tmPath);

            SearchResults results = tm.LanguageDirection.SearchText(GetSearchSettings(), "A dialog box will open.");
            #endregion

            #region "output"
            string tuInfo = string.Empty;
            foreach (SearchResult item in results)
            {
                if (item.ScoringResult.Match == 100)
                {
                    TranslationUnit tu        = item.MemoryTranslationUnit;
                    SystemFields    sysFields = tu.SystemFields;

                    tuInfo  = "Creation date: " + sysFields.CreationUser + "\n";
                    tuInfo += "Creation user: "******"\n";
                    tuInfo += "Change date: " + sysFields.ChangeDate + "\n";
                    tuInfo += "Change user: "******"\n";
                    tuInfo += "Usage count: " + sysFields.UseCount + "\n";
                    tuInfo += "Last used on: " + sysFields.UseDate + "\n";
                    tuInfo += "Last used by: " + sysFields.UseUser + "\n";
                    break;
                }
            }

            MessageBox.Show(tuInfo, "TU Information");
            #endregion
        }
Ejemplo n.º 2
0
        public void InvalidReadField(ResourceId resourceId, CommonMapperValue.ValidReadId validId, CommonMapperValue.InvalidRead invalidRead)
        {
            string deleteUUID         = PreparedDeletedFieldId.Data[$"{resourceId}{IndexDeleted}"].ToString();
            string fieldFirstUUID     = PreparedFieldId.Data[$"{resourceId}0"].ToString();
            string fieldSecondUUID    = PreparedFieldId.Data[$"{resourceId}1"].ToString();
            string appFieldFirstUUID  = ApplicationFieldId.Data[resourceId].ToString();
            string appFieldSecondUUID = SecondApplicationFieldId.Data[resourceId].ToString();
            string sysFieldUUID       = SystemFields.GetSytemFieldUuidByFieldType(resourceId, NumberFieldTestData.TestingFieldType);
            var    request            = CommonMapperValue.ValidReadUUIDMapperValue[validId](fieldFirstUUID, fieldSecondUUID, appFieldFirstUUID, appFieldSecondUUID, sysFieldUUID);

            CommonMapperValue.InvalidReadMapperValue[invalidRead](deleteUUID, request);
            var handler  = new DefaultManager();
            var response = handler.Send <FieldDetailsResponse>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest), "Could not read field details");
        }
Ejemplo n.º 3
0
        public void ValidReadUserField(ResourceId resourceId, CommonMapperValue.ValidReadId validId, Selects.ValidSelect validSelect)
        {
            string fieldFirstUUID     = PreparedFieldId.Data[$"{resourceId}0"].ToString();
            string fieldSecondUUID    = PreparedFieldId.Data[$"{resourceId}1"].ToString();
            string appFieldFirstUUID  = ApplicationFieldId.Data[resourceId].ToString();
            string appFieldSecondUUID = SecondApplicationFieldId.Data[resourceId].ToString();
            string sysFieldUUID       = SystemFields.GetSytemFieldUuidByFieldType(resourceId, NumberFieldTestData.TestingFieldType);
            var    request            = CommonMapperValue.ValidReadUUIDMapperValue[validId](fieldFirstUUID, fieldSecondUUID, appFieldFirstUUID, appFieldSecondUUID, sysFieldUUID);

            request.AddRange(Selects.SelectMapperValue[validSelect]);
            var handler  = new DefaultManager();
            var response = handler.Send <FieldDetailsResponse>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Could not read field details");
            Selects.VerifyContainExpectedSelect(response.Result, validSelect);
        }
Ejemplo n.º 4
0
        public string GetFieldName(string tableKey, string fieldKey)
        {
            if (Tables != null && Tables.ContainsKey(tableKey))
            {
                if (Tables[tableKey].Fields.ContainsKey(fieldKey))
                {
                    return(Tables[tableKey].Fields[fieldKey]);
                }

                if (SystemFields != null && SystemFields.ContainsKey(fieldKey))
                {
                    return(SystemFields[fieldKey]);
                }

                return(fieldKey);
            }
            else
            {
                return(fieldKey);
            }
        }
Ejemplo n.º 5
0
        public void InvalidTests(string param, Invalid invalid)
        {
            // Generate request
            var id         = SystemFields.GetSystemFieldId(ResourceId.Client, SystemFieldAlias);
            var dictionary = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(Selects.IdParam, id.ToString())
            };

            dictionary.AddRange(Selects.SelectMapperValue[Selects.ValidSelect.DisplayLabel]);

            // Replace invalid parameter value
            var index = dictionary.FindIndex(x => x.Key == param);

            dictionary[index] = InvalidMapper[invalid](param);

            // Execute test
            var defaultManager = new DefaultManager();
            var result         = defaultManager.Send <FieldDetailsResponse>(FieldManager.FieldHandlingRelativeUrl, dictionary, HttpMethod.GET);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still read field details successfully");
        }
Ejemplo n.º 6
0
        public void TestReadFieldInvalid(ResourceId resource, ValidReadId validReadId, InvalidRead invalidRead)
        {
            var firstUuidUser  = FieldsCreator.Data[$"{resource}-{Defines.FieldTypeApi.ToString()}-0"].Guid.ToString();
            var secondUuidUser = FieldsCreator.Data[$"{resource}-{Defines.FieldTypeApi.ToString()}-1"].Guid.ToString();
            var firstUuidApp   = TextHelpers.Guid[TextHelpers.FieldTypes.Application](resource, null, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First()).ToString();
            var secondUuidApp  = TextHelpers.Guid[TextHelpers.FieldTypes.Application](resource, null, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().Last()).ToString();
            var deletedUuid    = FieldsCreator.Data[$"{resource}-{Defines.FieldTypeApi.ToString()}-2"].Guid.ToString();

            var request = ValidReadUUIDMapperValue[validReadId](firstUuidUser, secondUuidUser, firstUuidApp, secondUuidApp, SystemFields.GetSytemFieldUuidByFieldType(resource, FieldType.SingleLineText));

            InvalidReadMapperValue[invalidRead](deletedUuid, request);

            var handler  = new DefaultManager();
            var response = handler.Send <FieldDetailsResponseItem>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Ejemplo n.º 7
0
        public void TestReadFieldValid(ResourceId resource, ValidReadId validReadId, Selects.ValidSelect select)
        {
            var firstUuidUser  = FieldsCreator.Data[$"{resource}-{Defines.FieldTypeApi.ToString()}-0"].Guid.ToString();
            var secondUuidUser = FieldsCreator.Data[$"{resource}-{Defines.FieldTypeApi.ToString()}-1"].Guid.ToString();
            var firstUuidApp   = TextHelpers.Guid[TextHelpers.FieldTypes.Application](resource, null, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First()).ToString();
            var secondUuidApp  = TextHelpers.Guid[TextHelpers.FieldTypes.Application](resource, null, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().Last()).ToString();

            var idParams = ValidReadUUIDMapperValue[validReadId](firstUuidUser, secondUuidUser, firstUuidApp, secondUuidApp, SystemFields.GetSytemFieldUuidByFieldType(resource, FieldType.SingleLineText));
            var sel      = Selects.SelectMapperValue[select];
            var request  = new List <KeyValuePair <string, string> >();

            request.AddRange(idParams);
            request.AddRange(sel);
            var handler  = new DefaultManager();
            var response = handler.Send <FieldDetailsResponse>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));

            //Verify
            Selects.VerifyContainExpectedSelect(response.Result, select);
        }