Example #1
0
 public static void AddCreator(ResourceCreator creator)
 {
     if (!_creators.ContainsKey(creator.ResourceType))
     {
         _creators.Add(creator.ResourceType, creator);
     }
 }
Example #2
0
        /// <summary>
        /// Creates an instance of Attachment
        /// </summary>
        /// <returns></returns>
        private Attachment CreateAttachmentInstance()
        {
            string clientId      = string.Empty;
            var    clientCreator = new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection());

            if (PublicAPI.PublicAPISetUp.ListClientId != null && PublicAPISetUp.ListClientId.Count > 0)
            {
                clientId = PublicAPISetUp.ListClientId.Random();
            }
            else
            {
                clientId = clientCreator.Create();
                Assume.That(!string.IsNullOrEmpty(clientId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Client"));
                PublicAPISetUp.ListClientId.Add(clientId);
            }

            byte[] byteContent = Util.ReadBinaryFile(Util.GetTestDirectory() + System.IO.Path.DirectorySeparatorChar + DataFolder + System.IO.Path.DirectorySeparatorChar + TxtFilePath);
            string content     = Util.BytesToBase64String(byteContent);

            Attachment resource = new Attachment
            {
                Id          = "-1",
                Resource    = ((int)Enums.ResourceType.Client).ToString(),
                ResourceId  = clientId,
                FileName    = "abc.txt",
                ContentType = Enums.ContentType.Txt,
                Content     = content,
            };

            return(resource);
        }
Example #3
0
        public void TestWriteAttachmentPerResource(Enums.ResourceType resourceType)
        {
            var    attachmentCreator = new ResourceCreator <Attachment>(PublicApiAdapter.CreateAdapterForDefaultConnection());
            string attachmentId      = attachmentCreator.Create((int)resourceType);

            Assert.That(!String.IsNullOrEmpty(attachmentId), "Create attachment file failed");

            // temporary statement
            switch (resourceType)
            {
            case Enums.ResourceType.Sales:
            case Enums.ResourceType.Contract:
            case Enums.ResourceType.Activity:
                Assert.That(attachmentId, Is.Not.Null.And.Not.Empty, "Create attachment file of resource type {0}", resourceType);
                break;

            default:
                Dictionary <string, object> urlParameters = new Dictionary <string, object>()
                {
                    { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                    { "requestType", "1" },
                    { "resource", (int)resourceType },
                    { "id", attachmentId }
                };
                ReadResponseData <Attachment> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Attachment>(urlParameters);
                Assert.That(0 == result.Code, "Read attachment file failed.");

                Assert.AreEqual(attachmentId, result.Items[0].Id);
                Assert.AreEqual(((int)resourceType).ToString(), result.Items[0].Resource);
                break;
            }
        }
        private Job CreateJob()
        {
            string clientId    = string.Empty;
            string recruiterId = string.Empty;

            if (PublicAPISetUp.ListClientId.Count > 0)
            {
                clientId = PublicAPISetUp.ListClientId.Random();
            }
            else
            {
                clientId = new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection()).Create();
                Assume.That(!string.IsNullOrEmpty(clientId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Client"));
                PublicAPISetUp.ListClientId.Add(clientId);
            }
            recruiterId = CreateRecruiterResourceSpecifiedData(clientId);
            Assume.That(!string.IsNullOrEmpty(recruiterId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Recruiter"));
            Job resource = new Job
            {
                Id        = "-1",
                Owner     = "1",
                Client    = clientId,
                Recruiter = recruiterId,
                Position  = "Specified Data Position"
            };

            return(resource);
        }
Example #5
0
        public void TestUpdateItemsOrderStatusShipped()
        {
            SetOrderShipped();
            var resourceToUpdate = ResourceCreator.GetRandomCreateResource();

            var response = ResourceCreator.Update(CreatedResource.Id, resourceToUpdate);

            AssertBadRequestReason(response, BadRequestReasonExtended.OrderNotPending);
        }
Example #6
0
        public virtual void TestFamilyUpdate()
        {
            var resourceToUpdate = ResourceCreator.GetRandomCreateResource();

            ResourceCreator.Update(CreatedResource.Id, resourceToUpdate);
            var category = ResourcesHolder.GetLastOrCreate <DepartmentResource>().Value;

            Assert.AreEqual(resourceToUpdate.FamilyName, category.Families.First().Name);
            Assert.AreEqual(resourceToUpdate.Name, category.Families.First().Categories.First().Name);
        }
Example #7
0
    public static TranslationConfigurationSO getOrCreateGameTranslationConfig(string groupid)
    {
        string fileName = ResourceLoadFacade.TranslationConfigurationSOFileNameFromGroupID(groupid);
        TranslationConfigurationSO config =
            ResourceLoadFacade.LoadConfigGroup(groupid) ??
            ResourceCreator.CreateSO <TranslationConfigurationSO>(fileName);

        config.translation_set_group = groupid;
        return(config);
    }
Example #8
0
        /// <summary>
        /// Prepare data of resources
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns>Id of resource</returns>
        protected string PrepareResourceData <T>() where T : XmlResource, new()
        {
            string id         = new ResourceCreator <T>(PublicApiAdapter.CreateAdapterForDefaultConnection()).Create();
            int    resourceId = -1;
            bool   parsed     = Int32.TryParse(id, out resourceId);

            Assume.That(parsed);
            Assume.That(resourceId > 0, string.Format("The resource( {0} ) can not create!!!!!", typeof(T).Name));
            return(id);
        }
        /// <summary>
        /// Prepare Attachment Data
        /// </summary>
        /// <param name="resourceTypeAttachment">Resource Type</param>
        /// <param name="resourceEntryId">Resource Id</param>
        /// <returns>New Attachment Id as string</returns>
        private string PrepareAttachmentData(int resourceTypeAttachment, string resourceEntryId)
        {
            var    attachmentCreator = new ResourceCreator <Attachment>(publicApiAdapter);
            string id         = string.Empty;
            int    resourceId = -1;

            id = attachmentCreator.Create(resourceTypeAttachment, resourceEntryId);
            bool parsed = Int32.TryParse(id, out resourceId);

            Assume.That(parsed);
            Assume.That(resourceId > 0, "The resource(" + resourceTypeAttachment + ")" + " can not create!!!!!");
            return(id);
        }
Example #10
0
	// Use this for initialization
	void Start () {

        if(instance != null)
        {
            Destroy(this);
            return;

        }

        instance = this;

        humInstant = GameObject.FindObjectsOfType<HumanInstantiator>();

        


	}
Example #11
0
        public void TestWriteAttachmentFilename(int expectResultCode, string fileName)
        {
            var    clientCreator = new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection());
            int    resourceType  = (int)Enums.ResourceType.Client;
            string resourceId    = clientCreator.Create();

            Assert.That(!String.IsNullOrEmpty(resourceId));
            Attachment attachment = new Attachment()
            {
                Id          = "-1",
                Resource    = resourceType.ToString(),
                ResourceId  = resourceId,
                FileName    = fileName,
                ContentType = Enums.ContentType.Txt,
                Content     = "VGV4dCBjb250ZW50",
            };

            if (expectResultCode == Enums.PublicAPIResultCode.Success)
            {
                string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(attachment, null);

                int attachmentId = Int32.Parse(id);
                Dictionary <string, object> urlParameters = new Dictionary <string, object>()
                {
                    { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                    { "requestType", "1" },
                    { "resource", resourceType },
                    { "resourceId", resourceId }
                };
                ReadResponseData <Attachment> readResult = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Attachment>(urlParameters);
                Assert.That(0 == readResult.Code, "Read response data failed.");

                Assert.AreEqual(1, readResult.Count);
                Assert.AreEqual(resourceType.ToString(), readResult.Items[0].Resource);
                Assert.AreEqual(resourceId, readResult.Items[0].ResourceId);
                Assert.AreEqual(attachmentId.ToString(), readResult.Items[0].Id);
                Assert.AreEqual(fileName, readResult.Items[0].FileName);
            }
            else
            {
                // TODO: should be unified. string or int
                // Assert.AreEqual(expectResultCode, writeResultXml.Code, "wrong result code.");
                ErrorCode result = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(attachment, cleanupAction: null);
                Assert.AreEqual(expectResultCode, result.Code, "Wrong result code.");
            }
        }
        /// <summary>
        /// Creates a new Candidate
        /// </summary>
        /// <returns></returns>
        private string PrepareCandidate()
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            var    candidateCreator = new ResourceCreator <Candidate>(publicApiAdapter);
            string candidateId      = string.Empty;

            if (PublicAPISetUp.ListCandidateId.Count > 0)
            {
                candidateId = PublicAPISetUp.ListCandidateId.Random();
            }
            else
            {
                candidateId = candidateCreator.Create();
                Assume.That(!string.IsNullOrEmpty(candidateId));
                PublicAPISetUp.ListCandidateId.Add(candidateId);
            }
            return(candidateId);
        }
        public void TestCreateJobInvalidOption(string fieldAlias, string optionAlias)
        {
            string clientId = new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection()).Create();

            Assume.That(!string.IsNullOrEmpty(clientId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Client"));
            PublicAPISetUp.ListClientId.Add(clientId);

            Option fieldValue = new Option()
            {
                ActualXMLTag = optionAlias
            };
            Job resource = CreateJob();

            resource.DictionaryValues[fieldAlias] = fieldValue;
            ErrorCode error = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resource, cleanupAction: null);

            Assert.NotNull(error, "Error code is null!");
            Assert.AreEqual(Enums.PublicAPIResultCode.InvalidParameterValue, error.Code, "Wrong error code!");
        }
Example #14
0
        public void TestUpdateCandidateMultipleLineNumberCharacters(int numChar)
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            var    candidateCreator = new ResourceCreator <Candidate>(publicApiAdapter);
            string candidateId      = string.Empty;

            if (PublicAPISetUp.ListCandidateId.Count > 0)
            {
                candidateId = PublicAPISetUp.ListCandidateId.Random();
            }
            else
            {
                candidateId = candidateCreator.Create();
                Assume.That(!string.IsNullOrEmpty(candidateId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));
                PublicAPISetUp.ListCandidateId.Add(candidateId);
            }


            string    memo     = Util.GetUniqueString(numChar, false);
            Candidate resource = new Candidate
            {
                Id   = candidateId,
                Memo = memo,
            };

            candidateId = publicApiAdapter.WriteSuccess(resource, null);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(candidateId, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, "Candidate"));

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Person.P_Memo", resource.Memo },
            };

            VerifyFieldData(resourceId, fields);
        }
        private string PrepareClient()
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            var    clientsCreator   = new ResourceCreator <Client>(publicApiAdapter);
            string id = string.Empty;

            if (PublicAPISetUp.ListClientId.Count > 0)
            {
                id = PublicAPISetUp.ListClientId.Random();
            }
            else
            {
                id = clientsCreator.Create();
                int  resourceId = -1;
                bool parsed     = Int32.TryParse(id, out resourceId);
                Assume.That(parsed);
                Assume.That(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Activity"));
                PublicAPISetUp.ListClientId.Add(id);
            }
            return(id);
        }
Example #16
0
        public void TestUpdateCandidate(string fieldName, object fieldValue)
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            var    candidateCreator = new ResourceCreator <Candidate>(publicApiAdapter);
            string candidateId      = string.Empty;

            if (PublicAPISetUp.ListCandidateId.Count > 0)
            {
                candidateId = PublicAPISetUp.ListCandidateId.Random();
            }
            else
            {
                candidateId = candidateCreator.Create();
                Assume.That(!string.IsNullOrEmpty(candidateId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));
                PublicAPISetUp.ListCandidateId.Add(candidateId);
            }

            Candidate candidate = new Candidate()
            {
                Id = candidateId
            };

            candidate.DictionaryValues[fieldName] = fieldValue;
            string id = publicApiAdapter.WriteSuccess(candidate, null);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(id, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));

            Dictionary <string, object> fields = new Dictionary <string, object>()
                                                 //{ { fieldName.Split('.')[1], fieldValue } };
            {
                { fieldName, fieldValue }
            };

            VerifyFieldData(resourceId, fields);
        }
    private static void saveSet(TransfluentLanguage language, Dictionary <string, string> pairs, string groupid = null)
    {
        try
        {
            string             languageCode = language.code;
            GameTranslationSet set          = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(languageCode) ??
                                              ResourceCreator.CreateSO <GameTranslationSet>(
                GameTranslationGetter.fileNameFromLanguageCode(languageCode));
            if (set.language == null)
            {
                set.language = language;
            }
            set.mergeInSet(groupid, pairs);

            EditorUtility.SetDirty(set);
            AssetDatabase.SaveAssets();
        }
        catch (Exception e)
        {
            Debug.LogError("error while saving imported translations:" + e.Message + " stack:" + e.StackTrace);
        }
    }
Example #18
0
        public IEnumerable <App> Create()
        {
            foreach (var component in ComponentRepository.GetAll())
            {
                foreach (var type in AppTypeProvider.GetTypes(component))
                {
                    var attribute = CustomAttributeExtensions.GetCustomAttribute <AppAttribute>(type);

                    var translationAttribute = CustomAttributeExtensions.GetCustomAttribute <TranslationsAttribute>(type);
                    var translations         = translationAttribute != null?TranslationRepositoryCreator.Create(component.Id + "/" + translationAttribute.Path) : new EmptyTranslationRepository();

                    yield return(new App(
                                     attribute.Id,
                                     component,
                                     scripts: ScriptCreator.Create(component.Id, type),
                                     styles: StyleCreator.Create(component.Id, type),
                                     resources: ResourceCreator.Create(component.Id, type),
                                     translations: translations
                                     ));
                }
            }
        }
        private ActionResult CreateResource(string container, string file, bool isDirectory,
                                            string contents, bool rewriteFile = false)
        {
            try
            {
                var resource = new ResourceCreator
                {
                    Container   = container,
                    File        = file,
                    IsDirectory = isDirectory,
                    Contents    = contents,
                    Rewrite     = rewriteFile
                };

                resource.Create(this.Tenant);
            }
            catch (ResourceCreateException ex)
            {
                return(this.Failed(ex.Message, HttpStatusCode.InternalServerError));
            }

            return(this.Ok());
        }
Example #20
0
        public void TestUpdateCandidateWithPhase()
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            var    candidateCreator = new ResourceCreator <Candidate>(publicApiAdapter);
            string candidateId      = string.Empty;

            if (PublicAPISetUp.ListCandidateId.Count > 0)
            {
                candidateId = PublicAPISetUp.ListCandidateId.Random();
            }
            else
            {
                candidateId = candidateCreator.Create();
                Assume.That(!string.IsNullOrEmpty(candidateId), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));
                PublicAPISetUp.ListCandidateId.Add(candidateId);
            }

            Candidate candidate = new Candidate()
            {
                Id    = candidateId,
                Phase = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.CandidatePhase).Random()
                },
                PhaseDate = Util.ToString(DateTime.Now)
            };

            candidateId = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(candidate, null);
            Assert.That(candidateId, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));

            Dictionary <string, object> fields = new Dictionary <string, object>();

            fields.Add("Person.P_Phase", (candidate.Phase as Option).ActualXMLTag);

            VerifyFieldData(int.Parse(candidateId), fields);
        }
    public void testLanguageListGetterWithNoList()
    {
        //LanguageList list = ResourceLoadAdapter.getLanguageList();
        //Assets/Transfluent/Resources/LanguageList.asset
        string languageListPath = "Assets/Transfluent/Resources/LanguageList.asset";

        AssetDatabase.DeleteAsset(languageListPath);
        IWebService            service = new SyncronousEditorWebRequest();
        var                    request = new RequestAllLanguages();
        WebServiceReturnStatus status  = service.request(request);
        LanguageList           list    = request.Parse(status.text);

        Assert.NotNull(list);
        Assert.NotNull(list.languages);
        Assert.Greater(list.languages.Count, 0);

        var so = ResourceCreator.CreateSO <LanguageListSO>("LanguageList");

        so.list = list;
        EditorUtility.SetDirty(so);

        LanguageList newList = ResourceLoadFacade.getLanguageList();

        //NOTE: THIS IS THE RUNTIME VERSION... not the editor time version

        AssetDatabase.SaveAssets();
        //manual load

        var fromDisk = AssetDatabase.LoadAssetAtPath(languageListPath, typeof(LanguageListSO)) as LanguageListSO;

        Assert.NotNull(fromDisk);
        Assert.NotNull(fromDisk.list);
        Assert.NotNull(fromDisk.list.languages);
        Assert.Greater(fromDisk.list.languages.Count, 0);
        Debug.Log("newlist:" + JsonWriter.Serialize(newList));
    }
        public void TestReCreate()
        {
            var response = ResourceCreator.Create(new CartCreateResource());

            AssertBadRequestReason(response, BadRequestReason.SameExists);
        }