Пример #1
0
        public void TVFileLanguageService_PostAddTVFileLanguageDB_Add_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        LanguageEnum        LangToAdd           = LanguageEnum.en;
                        TVFileLanguageModel tvFileLanguageModel = AddTVFileLanguageModel(LangToAdd);
                        Assert.AreEqual("", tvFileLanguageModel.Error);

                        LangToAdd = LanguageEnum.es;
                        tvFileLanguageModelNew.TVFileID        = tvFileLanguageModel.TVFileID;
                        tvFileLanguageModelNew.FileDescription = tvFileLanguageModel.FileDescription;
                        FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);

                        //string ErrorText = "ErrorText";
                        shimTVFileLanguageService.FillTVFileLanguageTVFileLanguageTVFileLanguageModelContactOK = (a, b, c) =>
                        {
                            return("");
                        };

                        TVFileLanguageModel tvFileLanguageModelRet = tvFileLanguageService.PostAddTVFileLanguageDB(tvFileLanguageModelNew);
                        Assert.IsTrue(tvFileLanguageModelRet.Error.StartsWith(string.Format(ServiceRes.CouldNotAddError_, "").Substring(0, 10)));
                    }
                }
            }
        }
Пример #2
0
        public TVFileLanguageModel GetTVFileLanguageModelWithTVFileIDAndLanguageDB(int TVFileID, LanguageEnum Language)
        {
            TVFileLanguageModel tvFileLanguageModel = (from c in db.TVFileLanguages
                                                       where c.TVFileID == TVFileID &&
                                                       c.Language == (int)Language
                                                       select new TVFileLanguageModel
            {
                Error = "",
                TVFileLanguageID = c.TVFileLanguageID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                TVFileID = c.TVFileID,
                Language = (LanguageEnum)c.Language,
                TranslationStatus = (TranslationStatusEnum)c.TranslationStatus,
                FileDescription = c.FileDescription,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).FirstOrDefault <TVFileLanguageModel>();

            if (tvFileLanguageModel == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.TVFileLanguage, ServiceRes.TVFileID + "," + ServiceRes.Language, TVFileID + "," + Language)));
            }

            return(tvFileLanguageModel);
        }
Пример #3
0
        public void TVFileLanguageService_PostUpdateTVFileLanguageDB_GetTVFileLanguageWithTVFileIDAndLanguageDB_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        FillTVFileLanguageModelUpdate(tvFileLanguageModelRet);

                        //string ErrorText = "ErrorText";
                        shimTVFileLanguageService.GetTVFileLanguageWithTVFileIDAndLanguageDBInt32LanguageEnum = (a, b) =>
                        {
                            return(null);
                        };

                        TVFileLanguageModel tvFileLanguageModelRet2 = tvFileLanguageService.PostUpdateTVFileLanguageDB(tvFileLanguageModelRet);
                        Assert.AreEqual(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.TVFileLanguage), tvFileLanguageModelRet2.Error);
                    }
                }
            }
        }
Пример #4
0
        public void TVFileLanguageService_PostDeleteTVFileLanguageDB_IsContactOK_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);

                    TVFileLanguageModel tvFileLanguageModelRet2 = UpdateTVFileLanguageModel(tvFileLanguageModelRet);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimTVFileLanguageService.IsContactOK = () =>
                        {
                            return(new ContactOK()
                            {
                                Error = ErrorText
                            });
                        };

                        TVFileLanguageModel tvFileLanguageModelRet3 = tvFileLanguageService.PostDeleteTVFileLanguageDB(tvFileLanguageModelRet2.TVFileID, LangToAdd);
                        Assert.AreEqual(ErrorText, tvFileLanguageModelRet3.Error);
                    }
                }
            }
        }
Пример #5
0
        public void TVFileLanguageService_FillTVFileLanguage_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum        LangToAdd           = LanguageEnum.es;
                    TVFileLanguageModel tvFileLanguageModel = AddTVFileLanguageModel(LangToAdd);
                    Assert.AreEqual("", tvFileLanguageModel.Error);

                    tvFileLanguageModelNew.TVFileID = tvFileLanguageModel.TVFileID;

                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);

                    ContactOK contactOK = tvFileLanguageService.IsContactOK();

                    string retStr = tvFileLanguageService.FillTVFileLanguage(tvFileLanguage, tvFileLanguageModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(contactOK.ContactTVItemID, tvFileLanguage.LastUpdateContactTVItemID);

                    contactOK = null;

                    retStr = tvFileLanguageService.FillTVFileLanguage(tvFileLanguage, tvFileLanguageModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(2, tvFileLanguage.LastUpdateContactTVItemID);
                }
            }
        }
Пример #6
0
        // Check
        public string TVFileLanguageModelOK(TVFileLanguageModel tvFileLanguageModel)
        {
            string retStr = FieldCheckNotZeroInt(tvFileLanguageModel.TVFileID, ServiceRes.TVFileID);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            retStr = _BaseEnumService.LanguageOK(tvFileLanguageModel.Language);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            retStr = FieldCheckNotEmptyAndMaxLengthString(tvFileLanguageModel.FileDescription, ServiceRes.FileDescription, 1000);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            retStr = _BaseEnumService.DBCommandOK(tvFileLanguageModel.DBCommand);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }
            return("");
        }
Пример #7
0
        public void TVFileLanguageService_PostUpdateTVFileLanguageDB_DoUpdateChanges_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        FillTVFileLanguageModelUpdate(tvFileLanguageModelRet);

                        string ErrorText = "ErrorText";
                        shimTVFileLanguageService.DoUpdateChanges = () =>
                        {
                            return(ErrorText);
                        };

                        TVFileLanguageModel tvFileLanguageModelRet2 = tvFileLanguageService.PostUpdateTVFileLanguageDB(tvFileLanguageModelRet);
                        Assert.AreEqual(ErrorText, tvFileLanguageModelRet2.Error);
                    }
                }
            }
        }
Пример #8
0
        public void TVFileLanguageService_PostAddTVFileContactLanguageDB_DoAddChanges_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        LanguageEnum        LangToAdd           = LanguageEnum.en;
                        TVFileLanguageModel tvFileLanguageModel = AddTVFileLanguageModel(LangToAdd);
                        Assert.AreEqual("", tvFileLanguageModel.Error);

                        LangToAdd = LanguageEnum.es;
                        tvFileLanguageModelNew.TVFileID        = tvFileLanguageModel.TVFileID;
                        tvFileLanguageModelNew.FileDescription = tvFileLanguageModel.FileDescription;
                        FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);

                        string ErrorText = "ErrorText";
                        shimTVFileLanguageService.DoAddChanges = () =>
                        {
                            return(ErrorText);
                        };

                        TVFileLanguageModel tvFileLanguageModelRet = tvFileLanguageService.PostAddTVFileContactLanguageDB(tvFileLanguageModelNew);
                        Assert.AreEqual(ErrorText, tvFileLanguageModelRet.Error);
                    }
                }
            }
        }
Пример #9
0
        public void TVFileLanguageService_PostAddTVFileContactLanguageDB_GetTVFileLanguageModelWithTVFileIDAndLanguageDB_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        LanguageEnum        LangToAdd           = LanguageEnum.en;
                        TVFileLanguageModel tvFileLanguageModel = AddTVFileLanguageModel(LangToAdd);
                        Assert.AreEqual("", tvFileLanguageModel.Error);

                        LangToAdd = LanguageEnum.es;
                        tvFileLanguageModelNew.TVFileID        = tvFileLanguageModel.TVFileID;
                        tvFileLanguageModelNew.FileDescription = tvFileLanguageModel.FileDescription;
                        FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);

                        //string ErrorText = "ErrorText";
                        shimTVFileLanguageService.GetTVFileLanguageModelWithTVFileIDAndLanguageDBInt32LanguageEnum = (a, b) =>
                        {
                            return(new TVFileLanguageModel());
                        };

                        TVFileLanguageModel tvFileLanguageModelRet = tvFileLanguageService.PostAddTVFileContactLanguageDB(tvFileLanguageModelNew);
                        Assert.AreEqual(string.Format(ServiceRes._AlreadyExists, ServiceRes.TVFileLanguage), tvFileLanguageModelRet.Error);
                    }
                }
            }
        }
Пример #10
0
        private void FillTVFileLanguageModelUpdate(TVFileLanguageModel tvFileLanguageModel)
        {
            tvFileLanguageModel.FileDescription   = randomService.RandomString("File Desc", 20);
            tvFileLanguageModel.TranslationStatus = TranslationStatusEnum.Translated;

            Assert.IsTrue(tvFileLanguageModel.FileDescription.Length == 20);
            Assert.IsTrue(tvFileLanguageModel.TranslationStatus == TranslationStatusEnum.Translated);
        }
Пример #11
0
        private void FillTVFileLanguageModelNew(LanguageEnum Language, TVFileLanguageModel tvFileLanguageModel)
        {
            tvFileLanguageModel.TVFileID          = tvFileLanguageModel.TVFileID;
            tvFileLanguageModel.Language          = Language;
            tvFileLanguageModel.FileDescription   = randomService.RandomString("TV Text", 20);
            tvFileLanguageModel.TranslationStatus = TranslationStatusEnum.Translated;

            Assert.IsTrue(tvFileLanguageModel.TVFileID != 0);
            Assert.IsTrue(tvFileLanguageModel.Language == Language);
            Assert.IsTrue(tvFileLanguageModel.FileDescription.Length == 20);
            Assert.IsTrue(tvFileLanguageModel.TranslationStatus == TranslationStatusEnum.Translated);
        }
Пример #12
0
 public void TVFileLanguageService_ReturnError_Good_Test()
 {
     foreach (CultureInfo culture in setupData.cultureListGood)
     {
         SetupTest(contactModelListGood[0], culture);
         using (TransactionScope ts = new TransactionScope())
         {
             string ErrorText = "ErrorText";
             TVFileLanguageModel tvFileLanguageModel = tvFileLanguageService.ReturnError(ErrorText);
             Assert.AreEqual(ErrorText, tvFileLanguageModel.Error);
         }
     }
 }
Пример #13
0
        public void TVFileLanguageService_PostAddTVFileLanguageDB_UserEmailNotValidated_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[2], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);
                    Assert.AreEqual(ServiceRes.EmailRequiresValidation, tvFileLanguageModelRet.Error);
                }
            }
        }
Пример #14
0
        public void TVFileLanguageService_PostAddTVFileLanguageDB_BadUser_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListBad[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);
                    Assert.AreEqual(ServiceRes.NeedToBeLoggedIn, tvFileLanguageModelRet.Error);
                }
            }
        }
Пример #15
0
        public void SetupTest(ContactModel contactModelToDo, CultureInfo culture)
        {
            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            contactModel           = contactModelToDo;
            user                   = new GenericPrincipal(new GenericIdentity(contactModel.LoginEmail, "Forms"), null);
            tvFileService          = new TVFileService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            tvFileLanguageService  = new TVFileLanguageService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            testDBService          = new TestDBService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user, TableName, Plurial);
            randomService          = new RandomService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            tvItemService          = new TVItemService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            tvFileLanguageModelNew = new TVFileLanguageModel();
            tvFileLanguage         = new TVFileLanguage();
        }
Пример #16
0
        private TVFileLanguageModel UpdateTVFileLanguageModel(TVFileLanguageModel tvFileLanguageModelRet)
        {
            FillTVFileLanguageModelUpdate(tvFileLanguageModelRet);

            TVFileLanguageModel tvFileLanguageModelRet2 = tvFileLanguageService.PostUpdateTVFileLanguageDB(tvFileLanguageModelRet);

            if (!string.IsNullOrWhiteSpace(tvFileLanguageModelRet2.Error))
            {
                return(tvFileLanguageModelRet2);
            }

            Assert.IsNotNull(tvFileLanguageModelRet2);
            CompareTVFileLanguageModels(tvFileLanguageModelRet, tvFileLanguageModelRet2);

            return(tvFileLanguageModelRet2);
        }
Пример #17
0
        public TVFileLanguageModel PostUpdateTVFileLanguageDB(TVFileLanguageModel tvFileLanguageModel)
        {
            string retStr = TVFileLanguageModelOK(tvFileLanguageModel);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            TVFileLanguage tvFileLanguageToUpdate = GetTVFileLanguageWithTVFileIDAndLanguageDB(tvFileLanguageModel.TVFileID, tvFileLanguageModel.Language);

            if (tvFileLanguageToUpdate == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.TVFileLanguage)));
            }

            retStr = FillTVFileLanguage(tvFileLanguageToUpdate, tvFileLanguageModel, contactOK);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                retStr = DoUpdateChanges();
                if (!string.IsNullOrWhiteSpace(retStr))
                {
                    return(ReturnError(retStr));
                }

                LogModel logModel = _LogService.PostAddLogForObj("TVFileLanguages", tvFileLanguageToUpdate.TVFileLanguageID, LogCommandEnum.Change, tvFileLanguageToUpdate);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                ts.Complete();
            }
            return(GetTVFileLanguageModelWithTVFileIDAndLanguageDB(tvFileLanguageToUpdate.TVFileID, (LanguageEnum)tvFileLanguageToUpdate.Language));
        }
Пример #18
0
        // Post
        public TVFileLanguageModel PostAddTVFileLanguageDB(TVFileLanguageModel tvFileLanguageModel)
        {
            string retStr = TVFileLanguageModelOK(tvFileLanguageModel);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            TVFileLanguageModel tvFileLanguageModelExist = GetTVFileLanguageModelWithTVFileIDAndLanguageDB(tvFileLanguageModel.TVFileID, tvFileLanguageModel.Language);

            if (string.IsNullOrWhiteSpace(tvFileLanguageModelExist.Error))
            {
                return(ReturnError(string.Format(ServiceRes._AlreadyExists, ServiceRes.TVFileLanguage)));
            }

            TVFileLanguage tvFileLanguageNew = new TVFileLanguage();

            retStr = FillTVFileLanguage(tvFileLanguageNew, tvFileLanguageModel, contactOK);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            db.TVFileLanguages.Add(tvFileLanguageNew);
            retStr = DoAddChanges();
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            LogModel logModel = _LogService.PostAddLogForObj("TVFileLanguages", tvFileLanguageNew.TVFileLanguageID, LogCommandEnum.Add, tvFileLanguageNew);

            if (!string.IsNullOrWhiteSpace(logModel.Error))
            {
                return(ReturnError(logModel.Error));
            }

            return(GetTVFileLanguageModelWithTVFileIDAndLanguageDB(tvFileLanguageNew.TVFileID, tvFileLanguageModel.Language));
        }
Пример #19
0
        public void TVFileLanguageService_GetTVFileLanguageModelCountDB_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.es;

                    TVFileLanguageModel tvFileModelLanguageRet = AddTVFileLanguageModel(LangToAdd);

                    int tvFileCount = tvFileLanguageService.GetTVFileLanguageModelCountDB();
                    Assert.AreEqual(testDBService.Count + 2, tvFileCount);
                }
            }
        }
Пример #20
0
        public void TVFileLanguageService_GetTVFileLanguageModelWithTVFileIDAndLanguageDB_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LanguageEnum.en);

                    TVFileLanguageModel tvFileLanguageModelRet2 = tvFileLanguageService.GetTVFileLanguageModelWithTVFileIDAndLanguageDB(tvFileLanguageModelRet.TVFileID, LanguageEnum.en);
                    Assert.AreEqual(tvFileLanguageModelRet.TVFileID, tvFileLanguageModelRet2.TVFileID);
                    Assert.AreEqual(tvFileLanguageModelRet.Language, tvFileLanguageModelRet2.Language);
                    Assert.AreEqual(LanguageEnum.en, tvFileLanguageModelRet2.Language);
                }
            }
        }
Пример #21
0
        public void TVFileLanguageService_PostAddTVFileContactLanguageDB_Good_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    LanguageEnum LangToAdd = LanguageEnum.en;

                    TVFileLanguageModel tvFileLanguageModelRet = AddTVFileLanguageModel(LangToAdd);

                    TVFileLanguageModel tvFileLanguageModelRet2 = UpdateTVFileLanguageModel(tvFileLanguageModelRet);

                    TVFileLanguageModel tvFileLanguageModelRet3 = tvFileLanguageService.PostDeleteTVFileLanguageDB(tvFileLanguageModelRet2.TVFileID, LangToAdd);
                    Assert.AreEqual("", tvFileLanguageModelRet3.Error);
                }
            }
        }
Пример #22
0
        // Fill
        public string FillTVFileLanguage(TVFileLanguage tvFileLanguageNew, TVFileLanguageModel tvFileLanguageModel, ContactOK contactOK)
        {
            tvFileLanguageNew.DBCommand          = (int)tvFileLanguageModel.DBCommand;
            tvFileLanguageNew.TVFileID           = tvFileLanguageModel.TVFileID;
            tvFileLanguageNew.Language           = (int)tvFileLanguageModel.Language;
            tvFileLanguageNew.TranslationStatus  = (int)tvFileLanguageModel.TranslationStatus;
            tvFileLanguageNew.FileDescription    = tvFileLanguageModel.FileDescription;
            tvFileLanguageNew.LastUpdateDate_UTC = DateTime.UtcNow;
            if (contactOK == null)
            {
                tvFileLanguageNew.LastUpdateContactTVItemID = 2;
            }
            else
            {
                tvFileLanguageNew.LastUpdateContactTVItemID = contactOK.ContactTVItemID;
            }

            return("");
        }
Пример #23
0
        public void TVFileLanguageService_TVFileLanguageModelOK_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                LanguageEnum LangToAdd = LanguageEnum.es;

                using (TransactionScope ts = new TransactionScope())
                {
                    TVFileLanguageModel tvFileLanguageModel = AddTVFileLanguageModel(LangToAdd);
                    Assert.AreEqual("", tvFileLanguageModel.Error);

                    tvFileLanguageModelNew.TVFileID = tvFileLanguageModel.TVFileID;

                    #region TVFileID
                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    tvFileLanguageModelNew.TVFileID = 0;

                    string retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull(string.Format(ServiceRes._IsRequired, ServiceRes.TVFileID), retStr);
                    #endregion TVFileID

                    #region Language
                    tvFileLanguageModelNew.TVFileID = tvFileLanguageModel.TVFileID;
                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    int Max = 2;
                    tvFileLanguageModelNew.Language = (LanguageEnum)1000;

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull(string.Format(ServiceRes._IsRequired, ServiceRes.Language), retStr);

                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    tvFileLanguageModelNew.Language = LanguageEnum.en;

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull("", retStr);
                    #endregion Language

                    #region FileDescription
                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    Max = 1000;
                    tvFileLanguageModelNew.FileDescription = randomService.RandomString("", 0);

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull("", retStr);

                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    tvFileLanguageModelNew.FileDescription = randomService.RandomString("", Max + 1);

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull(string.Format(ServiceRes._MaxLengthIs_, ServiceRes.Language, Max), retStr);

                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    tvFileLanguageModelNew.FileDescription = randomService.RandomString("", Max - 1);

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull("", retStr);

                    FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);
                    tvFileLanguageModelNew.FileDescription = randomService.RandomString("", Max);

                    retStr = tvFileLanguageService.TVFileLanguageModelOK(tvFileLanguageModelNew);
                    Assert.IsNotNull("", retStr);
                    #endregion TVText
                }
            }
        }
Пример #24
0
 private void CompareTVFileLanguageModels(TVFileLanguageModel tvFileLanguageModelNew, TVFileLanguageModel tvFileLanguageModelRet)
 {
     Assert.AreEqual(tvFileLanguageModelNew.Language, tvFileLanguageModelRet.Language);
     Assert.AreEqual(tvFileLanguageModelNew.FileDescription, tvFileLanguageModelRet.FileDescription);
 }
Пример #25
0
        private TVFileLanguageModel AddTVFileLanguageModel(LanguageEnum LangToAdd)
        {
            TVItemModel tvItemModelRoot = tvItemService.GetRootTVItemModelDB();

            if (!string.IsNullOrWhiteSpace(tvItemModelRoot.Error))
            {
                return new TVFileLanguageModel()
                       {
                           Error = tvItemModelRoot.Error
                       }
            }
            ;


            TVItemModel tvItemModelFile = tvItemService.PostAddChildTVItemDB(tvItemModelRoot.TVItemID, "Unique File Name", TVTypeEnum.File);

            if (!string.IsNullOrWhiteSpace(tvItemModelFile.Error))
            {
                return new TVFileLanguageModel()
                       {
                           Error = tvItemModelFile.Error
                       }
            }
            ;

            TVFileModel tvFileModelNew = new TVFileModel()
            {
                ClientFilePath      = randomService.RandomString("", 20),
                FileCreatedDate_UTC = DateTime.Now,
                FileInfo            = randomService.RandomString("", 20),
                FileDescription     = randomService.RandomString("", 20),
                FilePurpose         = FilePurposeEnum.Picture,
                FileSize_kb         = randomService.RandomInt(10, 20),
                FileType            = FileTypeEnum.JPEG,
                FromWater           = false,
                Language            = LanguageEnum.en,
                ServerFileName      = randomService.RandomString("", 20),
                ServerFilePath      = randomService.RandomString("", 20),
                TemplateTVType      = (int)TVTypeEnum.Error,
                TVFileTVItemID      = tvItemModelFile.TVItemID,
            };

            TVFileModel tvFileModelRet = tvFileService.PostAddTVFileDB(tvFileModelNew);

            if (!string.IsNullOrWhiteSpace(tvFileModelRet.Error))
            {
                return new TVFileLanguageModel()
                       {
                           Error = tvFileModelRet.Error
                       }
            }
            ;

            //TVFileLanguageModel tvFileLanguageModelNew = new TVFileLanguageModel();
            //tvFileLanguageModelNew.TVFileID = tvFileModelRet.TVFileID;
            //tvFileLanguageModelNew.FileDescription = tvFileModelNew.FileDescription;
            //FillTVFileLanguageModelNew(LangToAdd, tvFileLanguageModelNew);

            TVFileLanguageModel tvFileLanguagModelRet = tvFileLanguageService.GetTVFileLanguageModelWithTVFileIDAndLanguageDB(tvFileModelRet.TVFileID, LanguageEnum.en);

            if (!string.IsNullOrWhiteSpace(tvFileLanguagModelRet.Error))
            {
                return(tvFileLanguagModelRet);
            }

            //Assert.IsNotNull(tvFileLanguagModelRet);
            //CompareTVFileLanguageModels(tvFileLanguageModelNew, tvFileLanguagModelRet);

            return(tvFileLanguagModelRet);
        }