コード例 #1
1
 private NameValueCollection MailerFormValues()
 {
     var form = new FormCollection();
     form.Add("name", "name");
     form.Add("FromAddress", "*****@*****.**");
     form.Add("Body", "Hello world!");
     return form;
 }
コード例 #2
1
        public static FormCollection CreateDinnerFormCollection()
        {
            var form = new FormCollection();

            form.Add("Description", "Description");
            form.Add("Title", "New Test Dinner");
            form.Add("EventDate", "2010-02-14");
            form.Add("Address", "5 Main Street");
            form.Add("ContactPhone", "503-555-1212");
            return form;
        }
コード例 #3
1
ファイル: FakeData.cs プロジェクト: feanz/Example
        public FormCollection CreateUserForm()
        {
            var form = new FormCollection();
            form.Add("User", "user");
            form.Add("FirtsName", "first");
            form.Add("LastName", "last");
            form.Add("Email", "*****@*****.**");
            form.Add("RoleIds", "1,2");

            return form;
        }
コード例 #4
1
        public void EditServiceOrderTest()
        {
            string userName = "******";
            FormCollection formCollection = new FormCollection();
            formCollection.Add("Client", "BB4439C8-E0CA-4725-8108-56C788495ACB");
            formCollection.Add("BookingNumber", "");
            formCollection.Add("OrderNumber", "");
            List<BusinessApplicationByUser> businessApplicationsByUser = AuthorizationBusiness.GetBusinessApplicationsByUser(userName);
            Guid businessApplicationId = businessApplicationsByUser.FirstOrDefault().Id;

            Guid serviceOrderId = new Guid("B2F4184A-B1A6-434F-948A-BCF17F1D4FEE");

            ServiceOrderBusiness.EditServiceOrder(formCollection, businessApplicationId, userName, serviceOrderId);
        }
コード例 #5
1
        public void Recalc_With_VendorCoupon()
        {
            var m_Controller = CreateController<ERPStore.Controllers.CartController>();
            m_Controller.AddCartItem("XBOX360");

            var formCollection = new FormCollection();
            formCollection.Add("quantity", "5");
            formCollection.Add("couponcode", "Vendor1");
            var result = (System.Web.Mvc.ViewResult)m_Controller.Recalc(formCollection);
            var cart = result.ViewData.Model as ERPStore.Models.OrderCart;
            Assert.IsNotNull(cart);
            Assert.IsNotNull(cart.Coupon);

            Assert.AreEqual(cart.Coupon.Type, ERPStore.Models.CouponType.VendorCode);

            Assert.AreEqual(result.ViewName, "Index");
        }
コード例 #6
0
 private FormCollection GetValidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("CommunicationTypeName", "test");
     formCollection.Add("CommunicationGroupId","1");
     return formCollection;
 }
コード例 #7
0
 public void TestInitialize()
 {
     fakeform = new FormCollection();
     fakeform.Add("ID", testid.ToString());
     fakeform.Add("workSiteAddress1", "blah");     //Every required field must be populated,
     fakeform.Add("city", "UnitTest");  //or result will be null.
     fakeform.Add("state", "WA");
     fakeform.Add("phone", "123-456-7890");
     fakeform.Add("zipcode", "12345-6789");
     fakeform.Add("typeOfWorkID", "1");
     fakeform.Add("dateTimeofWork", "1/1/2011");
     fakeform.Add("transportMethodID", "1");
     fakeform.Add("transportFee", "20.00");
     fakeform.Add("transportFeeExtra", "8.00");
     fakeform.Add("status", "43"); // active work order
     fakeform.Add("contactName", "test script contact name");
     //fakeform.Add("workerRequests", "30123,301234,30122,12345");
     _serv = new Mock<IWorkOrderService>();
     _empServ = new Mock<IEmployerService>();
     _waServ = new Mock<IWorkAssignmentService>();
     _reqServ = new Mock<IWorkerService>();
     _wrServ = new Mock<IWorkerRequestService>();
     workerRequest = new List<WorkerRequest> { };
     lcache = new Mock<ILookupCache>();
     dbfactory = new Mock<IDatabaseFactory>();
     _ctrlr = new WorkOrderController(_serv.Object, _waServ.Object, _empServ.Object, _reqServ.Object, _wrServ.Object, lcache.Object);
     _ctrlr.SetFakeControllerContext();
     // TODO: Include Lookups in Dependency Injection, remove initialize statements
     Lookups.Initialize(lcache.Object, dbfactory.Object);
 }
コード例 #8
0
 private FormCollection GetInvalidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("CustomFieldText", string.Empty);
     formCollection.Add("ModuleId", string.Empty);
     formCollection.Add("DataTypeID", string.Empty);
     return formCollection;
 }
コード例 #9
0
 private FormCollection GetInvalidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("DocumentTypeID", string.Empty);
     formCollection.Add("DocumentDate", string.Empty);
     formCollection.Add("EntityID", string.Empty);
     formCollection.Add("CreatedBy", string.Empty);
     formCollection.Add("CreatedDate", string.Empty);
     return formCollection;
 }
コード例 #10
0
        public void Given_a_valid_form_collection_When_MapCreateRequests_is_called_Then_returns_collection_of_NewlyAddedDocumentGridRowViewModel()
        {
            //Given
            var formCollection = new FormCollection();
            formCollection.Add("NotRelevantKey", "Some Value");
            formCollection.Add("DocumentGridRow_20000_DocumentLibraryId", "2000");
            formCollection.Add("DocumentGridRow_20000_FileName", "Test File 1.txt");
            formCollection.Add("DocumentGridRow_20000_Description", "First test file.");
            formCollection.Add("DocumentGridRow_20000_DocumentType", "6");
            formCollection.Add("DocumentGridRow_20001_DocumentLibraryId", "2001");
            formCollection.Add("DocumentGridRow_20001_FileName", "Test File 2.txt");
            formCollection.Add("DocumentGridRow_20001_Description", "Second test file.");
            formCollection.Add("DocumentGridRow_20001_DocumentType", "7");

            //When
            var documentRequestMapper = new DocumentRequestMapper();
            var newlyAddedDocumentGridRowViewModels = documentRequestMapper.MapCreateRequests(formCollection);

            //Then
            Assert.AreEqual(2, newlyAddedDocumentGridRowViewModels.Count);
            Assert.AreEqual(20000L, newlyAddedDocumentGridRowViewModels[0].DocumentLibraryId);
            Assert.AreEqual("Test File 1.txt", newlyAddedDocumentGridRowViewModels[0].Filename);
            Assert.AreEqual("First test file.", newlyAddedDocumentGridRowViewModels[0].Description);
            Assert.AreEqual(6L, (long)newlyAddedDocumentGridRowViewModels[0].DocumentType);
            Assert.AreEqual(20001L, newlyAddedDocumentGridRowViewModels[1].DocumentLibraryId);
            Assert.AreEqual("Test File 2.txt", newlyAddedDocumentGridRowViewModels[1].Filename);
            Assert.AreEqual("Second test file.", newlyAddedDocumentGridRowViewModels[1].Description);
            Assert.AreEqual(7L, (long)newlyAddedDocumentGridRowViewModels[1].DocumentType);
        }
コード例 #11
0
 public void AddServiceOrderTest()
 {
     string userName = "******";
     FormCollection formCollection = new FormCollection();
     formCollection.Add("Client", "BB4439C8-E0CA-4725-8108-56C788495ACB");
     formCollection.Add("BookingNumber", "");
     formCollection.Add("OrderNumber", "");
     List<BusinessApplicationByUser> businessApplicationsByUser = AuthorizationBusiness.GetBusinessApplicationsByUser(userName);
     Guid businessApplicationId = businessApplicationsByUser.FirstOrDefault().Id;
     ServiceOrderBusiness.AddServiceOrder(formCollection, businessApplicationId, userName);
 }
コード例 #12
0
ファイル: FakeToDoData.cs プロジェクト: NicholasMurray/YaToDo
        public static FormCollection CreateToDoFormCollection()
        {
            var form = new FormCollection();

            form.Add("Title", " Buy Bread");

            return form;
        }
コード例 #13
0
		/// <summary>
		/// Converts a route value dictionary to a form collection
		/// </summary>
		/// <param name="items"></param>
		/// <returns></returns>
		public static FormCollection ToFormCollection(this RouteValueDictionary items)
		{
			var formCollection = new FormCollection();
			foreach (var i in items)
			{
				formCollection.Add(i.Key, i.Value != null ? i.Value.ToString() : null);
			}
			return formCollection;
		}
コード例 #14
0
        public ActionResult Create( FormCollection form )
        {
            var badgesTable = new BadgesTable();

            form.Add( "creationdate", DateTime.Now.ToString() );

            var badge = badgesTable.Insert( form ); // TODO: get rid of mass assignment

            return RedirectToAction( "Index" );
        }
コード例 #15
0
        public void Given_a_valid_form_collection_When_MapDeleteRequests_is_called_Then_returns_a_list_of_ids()
        {
            //Given
            var formCollection = new FormCollection();
            formCollection.Add("NotRelevantKey", "Some Value");
            formCollection.Add("PreviouslyAddedDocumentsRow_20004_Delete", "true,false");
            formCollection.Add("PreviouslyAddedDocumentsRow_20005_Delete", "false");
            formCollection.Add("PreviouslyAddedDocumentsRow_20006_Delete", "true,false");

            //When
            var documentRequestMapper = new DocumentRequestMapper();
            var documentLibraryIdsToDelete =
                documentRequestMapper.MapDeleteRequests(formCollection);

            //Then
            Assert.AreEqual(2, documentLibraryIdsToDelete.Count);
            Assert.IsTrue(documentLibraryIdsToDelete.Contains(20004L));
            Assert.IsFalse(documentLibraryIdsToDelete.Contains(20005L));
            Assert.IsTrue(documentLibraryIdsToDelete.Contains(20006L));
        }
コード例 #16
0
        public void TestFormExtraction()
        {
            FormCollection form = new FormCollection();
            form.Add("Questions[2].Answer", "AnswerForQuestionTwo");
            form.Add("Questions[2].Notes", String.Empty);
            form.Add("Questions[4].Answer", "AnswerForQuestionFour");
            form.Add("Questions[4].Notes", "NotesForQuestionFour");

            IDictionary<int, SimpleQuestion> questions = SimpleQuestion.FromForm(form);
            Assert.NotNull(questions);
            Assert.False(0 == questions.Count);
            Assert.True(questions.ContainsKey(2));
            Assert.True(questions.ContainsKey(4));
            SimpleQuestion q2 = questions[2];
            Assert.NotNull(q2);
            Assert.AreEqual("AnswerForQuestionTwo", q2.Answer);
            Assert.IsTrue(String.IsNullOrEmpty(q2.Notes));
            SimpleQuestion q4 = questions[4];
            Assert.AreEqual("AnswerForQuestionFour", q4.Answer);
            Assert.AreEqual("NotesForQuestionFour", q4.Notes);
        }
コード例 #17
0
        public void Should_Add_A_Topic_When_Create_With_Post_Is_Called_And_Notify_The_User()
        {
            var professionalDevelopment = new Topic {Id = 3,
                Color = ColorTranslator.FromHtml("#000000"), Name = "Professional Development"};

            var collection = new FormCollection();
            collection.Add("Id", professionalDevelopment.Id.ToString());
            collection.Add("Name", professionalDevelopment.Name);
            collection.Add("Color", ColorTranslator.ToHtml(professionalDevelopment.Color).Trim('#'));

            topicRepository.SaveOrUpdate(professionalDevelopment);
            LastCall.IgnoreArguments();
            mocks.ReplayAll();

            var result = (RedirectToRouteResult) topicController.Create(collection);

            mocks.VerifyAll();

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Your topic has been added successfully.", topicController.TempData["message"]);
        }
コード例 #18
0
 protected void ItemToCollection(object item, FormCollection fc)
 {
     foreach (PropertyInfo prop in item.GetType().GetProperties())
     {
         if (prop.CanRead && prop.CanWrite)
         {
             object val = prop.GetValue(item, new object[] { });
             if (val != null)
                 fc.Add(prop.Name, val.ToString());
         }
     }
 }
コード例 #19
0
        //[TestMethod]
        public void test_03_create_and_delete_project()
        {
            var controller = new AdminController();

            HttpContextFactory.SetCurrentContext(GetMockedHttpContext());
            controller.ControllerContext = new ControllerContext(HttpContextFactory.Current,
                                              new RouteData(), controller);

            CurrentUser currentUser = CurrentUser.getInstance();
            currentUser.Studentnummer = 3000000;

            FormCollection n = new FormCollection();
            string exception = "";
            n.Add("FormProject.name", "TestProject");
            n.Add("FormProject.description", "TestDescription");
            n.Add("FormProject.start_date", "01/01/2001");
            n.Add("FormProject.end_date", "12/12/2012");
            try
            {
                var result = (RedirectToRouteResult) controller.Create(n);
                Assert.AreEqual("List", result.RouteValues["action"]);
            }
            catch (Exception e)
            {
                exception = e.ToString();
            }
            Assert.AreEqual(exception, "");

            exception = "";

            try{
                a.DeleteProject(8);
            }
            catch (Exception e)
            {
                exception = e.ToString();
            }

            Assert.AreEqual(exception, "");
        }
コード例 #20
0
        public void Should_Create_Topic_And_Notify_The_User()
        {
            var PerofessionalDevelopment = new Topic
                {
                    ID = 3
                    ,
                    Color = ColorTranslator.FromHtml("#000000"),
                    Name = "Perofessional Development"
                };

            var formValue = new FormCollection();
            formValue.Add("ID", PerofessionalDevelopment.ID.ToString());
            formValue.Add("Name", PerofessionalDevelopment.Name);
            formValue.Add("Color", PerofessionalDevelopment.ColorInWebHex().Trim('#'));

            var controller = new TopicController();

            var result = (RedirectToRouteResult)controller.Create(formValue);

            Assert.Contains(PerofessionalDevelopment, TopicSource.Topics);
            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Your topic has been successfully.", controller.TempData["Message"]);
        }
コード例 #21
0
 public void TestInitialize()
 {
     _wserv = new Mock<IWorkerService>();
     _pserv = new Mock<IPersonService>();
     _iserv = new Mock<IImageService>();
     _wcache = new Mock<IWorkerCache>();
     lcache = new Mock<ILookupCache>();
     dbfactory = new Mock<IDatabaseFactory>();
     _ctrlr = new WorkerController(_wserv.Object, _pserv.Object, _iserv.Object, _wcache.Object);
     _ctrlr.SetFakeControllerContext();
     fakeform = new FormCollection();
     fakeform.Add("ID", "12345");
     fakeform.Add("typeOfWorkID", "1");
     fakeform.Add("RaceID", "1");
     fakeform.Add("height", "1");
     fakeform.Add("weight", "1");
     fakeform.Add("englishlevelID", "1");
     fakeform.Add("recentarrival", "true");
     fakeform.Add("dateinUSA", "1/1/2000");
     fakeform.Add("dateinseattle", "1/1/2000");
     fakeform.Add("disabled", "true");
     fakeform.Add("maritalstatus", "1");
     fakeform.Add("livewithchildren", "true");
     fakeform.Add("numofchildren", "1");
     fakeform.Add("incomeID", "1");
     fakeform.Add("livealone", "true");
     fakeform.Add("emcontUSAname", "");
     fakeform.Add("emcontUSAphone", "");
     fakeform.Add("emcontUSArelation", "");
     fakeform.Add("dwccardnum", "12345");
     fakeform.Add("neighborhoodID", "1");
     fakeform.Add("immigrantrefugee", "false");
     fakeform.Add("countryoforiginID", "1");
     fakeform.Add("emcontoriginname", "");
     fakeform.Add("emcontoriginphone", "");
     fakeform.Add("emcontoriginrelation", "");
     fakeform.Add("memberexpirationdate", "1/1/2000");
     fakeform.Add("driverslicense", "false");
     fakeform.Add("licenseexpirationdate", "");
     fakeform.Add("carinsurance", "false");
     fakeform.Add("insuranceexpiration", "");
     fakeform.Add("dateOfBirth", "1/1/2000");
     fakeform.Add("dateOfMembership", "1/1/2000");
     //fakeform.Add("", "");
     // TODO: Include Lookups in Dependency Injection, remove initialize statements
     Lookups.Initialize(lcache.Object, dbfactory.Object);
 }
コード例 #22
0
 public void TestInitialize()
 {
     _waServ = new Mock<IWorkAssignmentService>();
     _wkrServ = new Mock<IWorkerService>();
     _woServ = new Mock<IWorkOrderService>();
     _wsiServ = new Mock<IWorkerSigninService>();
     lcache = new Mock<ILookupCache>();
     dbfactory = new Mock<IDatabaseFactory>();
     _ctrlr = new WorkAssignmentController(_waServ.Object, _wkrServ.Object, _woServ.Object, _wsiServ.Object, lcache.Object);
     _view = new WorkAssignmentIndex();
     _ctrlr.SetFakeControllerContext();
     fakeform = new FormCollection();
     fakeform.Add("ID", "12345");
     Lookups.Initialize(lcache.Object, dbfactory.Object);
 }
コード例 #23
0
        public static FormCollection ConvertEntityToFormCollection(object entity)
        {
            var form = new FormCollection();
            foreach (PropertyInfo prop in entity.GetType().GetProperties())
            {
                if (!prop.PropertyType.IsGenericType)
                {
                    var name = prop.Name;
                    var value = prop.GetValue(entity, null) ?? String.Empty;

                    form.Add(name, value.ToString());
                }
            }

            return form;
        }
コード例 #24
0
        public void TestSearch()
        {
            RestaurantController rc = new RestaurantController();

            int expected = 9; // Number of Restaurant's that have 'c' in it
            var input    = new System.Web.Mvc.FormCollection();

            input.Add("search", "c");

            var action = rc.Search(input) as ViewResult;
            var r      = (List <PLC.Restaurant>)action.Model;

            int actual = r.Count;

            Assert.AreEqual(expected, actual);
        }
コード例 #25
0
ファイル: ModuleControllerTest.cs プロジェクト: eternalwt/CMS
        public void Index()
        {
            // Arrange
            using (ModuleController controller = new ModuleController()) {

                FormCollection collection = new FormCollection();

                collection.Add("ModuleID", "0");

                // Act
                JsonResult result = controller.Create(collection) as JsonResult;

                // Assert
                Assert.AreEqual("Welcome to ASP.NET MVC!", result);
            }
        }
コード例 #26
0
        public JToken Run(string appName, string button, [FromBody] JToken body, string blockIdentify, [FromUri] int modelId = -1)
        {
            COREobject core        = COREobject.i;
            DBEntities context     = core.Context;
            User       currentUser = core.User;
            var        fc          = new M.FormCollection();
            var        inputObject = body as JObject;

            if (inputObject != null)
            {
                foreach (var pair in inputObject)
                {
                    fc.Add(pair.Key, pair.Value.ToString());
                }
            }

            // get block
            Block block = null;

            try
            {
                int blockId = Convert.ToInt32(blockIdentify);
                block = context.Blocks.FirstOrDefault(b => b.Id == blockId);
            }
            catch (FormatException)
            {
                block = context.Blocks.FirstOrDefault(b => b.Name.ToLower() == blockIdentify.ToLower() && b.WorkFlow.ApplicationId == core.Application.Id);
            }

            try
            {
                block = block ?? context.WorkFlows.FirstOrDefault(w => w.ApplicationId == core.Application.Id && w.InitBlockId != null).InitBlock;
            }
            catch (NullReferenceException)
            {
                return(null);
            }

            // RUN
            var result = new Modules.Tapestry.Tapestry(core).jsonRun(block, button, modelId, fc);

            return(result);
        }
コード例 #27
0
        public void FileController_FileEditSaveJSON_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                controllerAction = "FileEditSaveJSON";
                contactModel     = contactModelListGood[0];

                SetupTest(contactModel, culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    TVItemModel tvItemModelMunicipality = randomService.RandomTVItem(TVTypeEnum.Municipality);
                    Assert.AreEqual("", tvItemModelMunicipality.Error);

                    TVItemModel tvItemModelTVFile = tvItemService.PostAddChildTVItemDB(tvItemModelMunicipality.TVItemID, randomService.RandomString("FileName ", 20), TVTypeEnum.File);
                    Assert.AreEqual("", tvItemModelTVFile.Error);

                    TVFileModel tvFileModel = randomService.RandomTVFileModel(tvItemModelTVFile, true);
                    Assert.AreEqual("", tvFileModel.Error);

                    System.Web.Mvc.FormCollection fc = new System.Web.Mvc.FormCollection();
                    fc.Add("TVFileTVItemID", tvFileModel.TVFileTVItemID.ToString());
                    if (tvFileModel.FilePurpose == FilePurposeEnum.Information)
                    {
                        fc.Add("FilePurpose", ((int)FilePurposeEnum.Generated).ToString());
                    }
                    else
                    {
                        fc.Add("FilePurpose", ((int)FilePurposeEnum.Information).ToString());
                    }
                    fc.Add("FileDescription", randomService.RandomString("Bonjour ", 100));
                    fc.Add("SaveAsFileName", randomService.RandomString("aaa ", 20));
                    fc.Add("FromWater", true.ToString());

                    JsonResult jsonResult = controller.FileEditSaveJSON(fc) as JsonResult;
                    Assert.IsNotNull(jsonResult);
                    string retStr = (string)jsonResult.Data;
                    Assert.AreEqual("", retStr);
                }
            }
        }
 private FormCollection GetValidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("0_UnderlyingFundId", "1");
     formCollection.Add("0_DealId", "1");
     formCollection.Add("0_Amount", "1");
     formCollection.Add("0_DistributionDate", DateTime.MaxValue.ToString());
     formCollection.Add("TotalRows", "1");
     return formCollection;
 }
コード例 #29
0
ファイル: FormModel.cs プロジェクト: RichiL/feather-widgets
        /// <summary>
        /// Sanitizes the form collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        protected virtual void SanitizeFormCollection(FormCollection collection)
        {
            const char ReplacementSymbol = '_';
            var forbidenSymbols = new char[] { '-' };

            if (collection != null)
            {
                var forbidenKeys = collection.AllKeys.Where(k => k.IndexOfAny(forbidenSymbols) >= 0);
                foreach (var key in forbidenKeys)
                {
                    var newKey = key.ToCharArray();
                    for (int i = 0; i < newKey.Length; i++)
                    {
                        if (forbidenSymbols.Contains(newKey[i]))
                        {
                            newKey[i] = ReplacementSymbol;
                        }
                    }

                    collection.Add(new string(newKey), collection[key]);
                    collection.Remove(key);
                }
            }
        }
コード例 #30
0
        public void FileController_CreateDocumentFromTemplateJSON_Canada_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                controllerAction = "CreateDocumentFromTemplateJSON";
                contactModel     = contactModelListGood[0];

                SetupTest(contactModel, culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    TVItemModel tvItemModelRoot = tvItemService.GetRootTVItemModelDB();
                    Assert.AreEqual("", tvItemModelRoot.Error);

                    TVItemModel tvItemModelCanada = tvItemService.GetChildTVItemModelWithTVItemIDAndTVTextStartWithAndTVTypeDB(tvItemModelRoot.TVItemID, "Canada", TVTypeEnum.Country);
                    Assert.AreEqual("", tvItemModelRoot.Error);

                    DirectoryInfo di = new DirectoryInfo(tvFileService.GetServerFilePath(tvItemModelRoot.TVItemID));

                    if (!di.Exists)
                    {
                        di.Create();
                    }

                    di = new DirectoryInfo(tvFileService.GetServerFilePath(tvItemModelRoot.TVItemID));
                    Assert.IsTrue(di.Exists);

                    FileInfo fi = new FileInfo(tvFileService.GetServerFilePath(tvItemModelRoot.TVItemID) + "this_should_be_unique.docx");

                    if (!fi.Exists)
                    {
                        StreamWriter sw = new StreamWriter(fi.FullName);
                        sw.WriteLine("|||Testing document|||");
                        sw.Close();
                    }

                    string FileName = "this_should_be_unique.docx";
                    fi = new FileInfo(tvFileService.GetServerFilePath(tvItemModelRoot.TVItemID) + FileName);
                    Assert.IsTrue(fi.Exists);

                    TVItemModel tvItemModelFile = tvItemService.PostAddChildTVItemDB(tvItemModelRoot.TVItemID, FileName, TVTypeEnum.File);
                    Assert.AreEqual("", tvItemModelFile.Error);

                    TVFileModel tvFileModelNew = new TVFileModel();
                    tvFileModelNew.TVFileTVItemID = tvItemModelFile.TVItemID;

                    FillTVFileModel(tvFileModelNew);
                    tvFileModelNew.Language            = controller.LanguageRequest;
                    tvFileModelNew.FilePurpose         = FilePurposeEnum.Template;
                    tvFileModelNew.FileType            = FileTypeEnum.DOCX;
                    tvFileModelNew.FileDescription     = randomService.RandomString("File Description", 200);
                    tvFileModelNew.FileSize_kb         = (int)(fi.Length / 1024);
                    tvFileModelNew.FileInfo            = randomService.RandomString("File Info", 200);
                    tvFileModelNew.FileCreatedDate_UTC = DateTime.Now;
                    tvFileModelNew.ClientFilePath      = "";
                    tvFileModelNew.ServerFileName      = FileName;
                    tvFileModelNew.ServerFilePath      = tvFileService.ChoseEDriveOrCDrive(tvFileService.GetServerFilePath(tvItemModelRoot.TVItemID));

                    TVFileModel tvFileModelRet = tvFileService.PostAddTVFileDB(tvFileModelNew);
                    Assert.AreEqual("", tvFileModelRet.Error);

                    DocTemplateModel docTemplateModelNew = new DocTemplateModel()
                    {
                        TVType         = tvItemModelCanada.TVType,
                        TVFileTVItemID = tvFileModelRet.TVFileTVItemID,
                        FileName       = FileName,
                    };

                    DocTemplateModel docTemplateModelRet = docTemplateService.PostAddDocTemplateDB(docTemplateModelNew);
                    Assert.AreEqual("", docTemplateModelRet.Error);

                    System.Web.Mvc.FormCollection fc = new System.Web.Mvc.FormCollection();
                    fc.Add("TVItemID", tvItemModelCanada.TVItemID.ToString());
                    fc.Add("DocTemplateID", docTemplateModelRet.DocTemplateID.ToString());

                    JsonResult jsonResult = controller.CreateDocumentFromTemplateJSON(fc) as JsonResult;
                    Assert.IsNotNull(jsonResult);
                    string retStr = (string)jsonResult.Data;
                    Assert.AreEqual("", retStr);

                    AppTaskModel appTaskModel = appTaskService.GetAppTaskModelWithTVItemIDTVItemID2AndCommandDB(tvItemModelCanada.TVItemID, tvItemModelCanada.TVItemID, AppTaskCommandEnum.CreateDocumentFromTemplate);
                    Assert.AreEqual("", appTaskModel.Error);
                    Assert.AreEqual("", appTaskModel.Error);
                }
            }
        }
コード例 #31
0
        public void ContactController_ContactDeleteJSON_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                controllerAction = "ContactDeleteJSON";

                SetupTest(contactModelListGood[0], culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    // Act
                    TVItemModel tvItemModelSubsector = randomService.RandomTVItem(TVTypeEnum.Subsector);

                    Assert.AreEqual("", tvItemModelSubsector.Error);

                    TVItemModel tvItemModelMunicipality = tvItemService.PostAddChildTVItemDB(tvItemModelSubsector.TVItemID, "Unique Municipality Name", TVTypeEnum.Municipality);

                    Assert.AreEqual("", tvItemModelMunicipality.Error);

                    TVItemLinkModel tvItemLinkModelNew = new TVItemLinkModel()
                    {
                        FromTVItemID = tvItemModelMunicipality.TVItemID,
                        ToTVItemID   = contactModelListGood[0].ContactTVItemID,
                        FromTVType   = TVTypeEnum.Municipality,
                        ToTVType     = TVTypeEnum.Contact,
                        Ordinal      = 0,
                        TVLevel      = 0,
                        TVPath       = "p" + tvItemModelMunicipality.TVItemID + "p" + contactModelListGood[0].ContactTVItemID,
                    };

                    TVItemLinkModel tvItemLinkModel = tvItemLinkService.PostAddTVItemLinkDB(tvItemLinkModelNew);

                    Assert.AreEqual("", tvItemLinkModel.Error);

                    string      TelNumber      = "3873847847";
                    TVItemModel tvItemModelTel = tvItemService.PostAddChildTVItemDB(1, TelNumber, TVTypeEnum.Tel);

                    Assert.AreEqual("", tvItemModelTel.Error);

                    TelModel telModelNew = new TelModel()
                    {
                        TelNumber   = TelNumber,
                        TelType     = TelTypeEnum.Mobile,
                        TelTVItemID = tvItemModelTel.TVItemID,
                    };

                    TelModel telModel = telService.PostAddTelDB(telModelNew);

                    Assert.AreEqual("", telModel.Error);

                    tvItemLinkModelNew = new TVItemLinkModel()
                    {
                        FromTVItemID = contactModelListGood[0].ContactTVItemID,
                        ToTVItemID   = tvItemModelTel.TVItemID,
                        FromTVType   = TVTypeEnum.Contact,
                        ToTVType     = TVTypeEnum.Tel,
                        Ordinal      = 0,
                        TVLevel      = 0,
                        TVPath       = "p" + contactModelListGood[0].ContactTVItemID + "p" + tvItemModelTel.TVItemID,
                    };

                    tvItemLinkModel = tvItemLinkService.PostAddTVItemLinkDB(tvItemLinkModelNew);

                    Assert.AreEqual("", tvItemLinkModel.Error);

                    System.Web.Mvc.FormCollection fc = new System.Web.Mvc.FormCollection();
                    fc.Add("ParentTVItemID", tvItemModelMunicipality.TVItemID.ToString());
                    fc.Add("ContactTVItemID", contactModelListGood[0].ContactTVItemID.ToString());

                    JsonResult jsonResult = controller.ContactDeleteJSON(fc) as JsonResult;

                    Assert.IsNotNull(jsonResult);

                    string retStr = (string)jsonResult.Data;
                    Assert.AreEqual("", retStr);
                }
            }
        }
コード例 #32
0
 private FormCollection GetValidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("Name", "Test");
     return formCollection;
 }
コード例 #33
0
ファイル: HomeController.cs プロジェクト: QueroComer/Projeto
        private ActionResult ValidaCadastro(FormCollection cadastro)
        {
            DateTime data;

            dataConnection conexao = new dataConnection();

            if (string.IsNullOrEmpty(cadastro["Login"]))
            {
                ViewBag.Mensagem = "Preencha o campo de login!";
            }
            else if (string.IsNullOrEmpty(cadastro["Senha"]))
            {
                ViewBag.Mensagem = "Preecha o campo de senha!";
            }
            else if (string.IsNullOrEmpty(cadastro["Confirmacao"]))
            {
                ViewBag.Mensagem = "Preecha o campo de confirmação de senha!";
            }
            else if (string.IsNullOrEmpty(cadastro["Nome"]))
            {
                ViewBag.Mensagem = "Preecha o campo de nome!";
            }
            else if (string.IsNullOrEmpty(cadastro["DataNascimento"]))
            {
                ViewBag.Mensagem = "Preencha o campo de Data Nascimento!";
            }
            else if (!((cadastro["Senha"]).Equals(cadastro["Confirmacao"])))
            {
                ViewBag.Mensagem = "A confirmação de senha deve ser igual a senha!";
            }
            else if (string.IsNullOrEmpty(cadastro["Cep"]))
            {
                ViewBag.Mensagem = "Preecha o campo de Cep!";
            }
            else if (string.IsNullOrEmpty(cadastro["Endereco"]))
            {
                ViewBag.Mensagem = "Preecha o campo de Endereço!";
            }
            else if (string.IsNullOrEmpty(cadastro["Cidade"]))
            {
                ViewBag.Mensagem = "Preecha o campo de Cidade!";
            }
            else if (string.IsNullOrEmpty(cadastro["Estado"]))
            {
                ViewBag.Mensagem = "Preecha o campo de Estado!";
            }

            if (!DateTime.TryParse((cadastro["DataNascimento"]), out data))
            {
                ViewBag.Mensagem = "Digite uma data válida!";
            }

            if (String.IsNullOrEmpty(ViewBag.Messagem))
            {
                try
                {
                    conexao.Insert("usuarios", new string[] { "nom_usuario", "dt_nascimento", "email", "senha" }, new string[] { cadastro["Nome"], data.Year + "-" + data.Month + "-" + data.Day, cadastro["Login"], cadastro["Senha"] });
                    FormCollection frm = new FormCollection();
                    frm.Add("txt_usuario", cadastro["Login"]);
                    frm.Add("txt_senha", cadastro["Senha"]);
                    return this.Autenticar(frm);
                }
                catch
                {
                    ViewBag.Mensagem = "Erro ao inserir usuário!";
                }
            }

            return View("Cadastro", cadastro);
        }
コード例 #34
-1
 private FormCollection GetInvalidformCollection()
 {
     FormCollection formCollection = new FormCollection();
     formCollection.Add("Name", string.Empty);
     formCollection.Add("CountryId", string.Empty);
     return formCollection;
 }
コード例 #35
-1
 public void test_02_studentForm()
 {
     var controller = new AdminController();
     FormCollection a = new FormCollection();
     a.Add("student", "3000000");
     var result = (RedirectToRouteResult) controller.StudentForm(a);
     Assert.AreEqual("Student", result.RouteValues["action"]);
 }