public void ViewResponse_repQuestions_ItemDataBound_Method_With_2_Parameters_Call_With_Reflection_Exception_Thrown_Test()
        {
            // Arrange
            var sender = Fixture.Create <object>();

            object[] parametersOutRanged         = { sender, null, null };
            object[] parametersInDifferentNumber = { sender };
            var      viewResponse = new ViewResponse();
            var      methodName   = "repQuestions_ItemDataBound";

            // Act
            var repQuestionsItemDataBoundMethodInfo1 = viewResponse.GetType().GetMethod(methodName);
            var repQuestionsItemDataBoundMethodInfo2 = viewResponse.GetType().GetMethod(methodName);
            var returnType1 = repQuestionsItemDataBoundMethodInfo1.ReturnType;
            var returnType2 = repQuestionsItemDataBoundMethodInfo2.ReturnType;

            // Assert
            parametersOutRanged.ShouldNotBeNull();
            parametersInDifferentNumber.ShouldNotBeNull();
            returnType1.ShouldNotBeNull();
            returnType2.ShouldNotBeNull();
            returnType1.ShouldBe(returnType2);
            viewResponse.ShouldNotBeNull();
            repQuestionsItemDataBoundMethodInfo1.ShouldNotBeNull();
            repQuestionsItemDataBoundMethodInfo2.ShouldNotBeNull();
            repQuestionsItemDataBoundMethodInfo1.ShouldBe(repQuestionsItemDataBoundMethodInfo2);
            Should.Throw <Exception>(actual: () => repQuestionsItemDataBoundMethodInfo1.Invoke(viewResponse, parametersOutRanged));
            Should.Throw <Exception>(actual: () => repQuestionsItemDataBoundMethodInfo2.Invoke(viewResponse, parametersOutRanged));
            Should.Throw <Exception>(actual: () => repQuestionsItemDataBoundMethodInfo1.Invoke(viewResponse, parametersInDifferentNumber));
            Should.Throw <Exception>(actual: () => repQuestionsItemDataBoundMethodInfo2.Invoke(viewResponse, parametersInDifferentNumber));
            Should.Throw <TargetParameterCountException>(actual: () => repQuestionsItemDataBoundMethodInfo1.Invoke(viewResponse, parametersOutRanged));
            Should.Throw <TargetParameterCountException>(actual: () => repQuestionsItemDataBoundMethodInfo2.Invoke(viewResponse, parametersOutRanged));
            Should.Throw <TargetParameterCountException>(actual: () => repQuestionsItemDataBoundMethodInfo1.Invoke(viewResponse, parametersInDifferentNumber));
            Should.Throw <TargetParameterCountException>(actual: () => repQuestionsItemDataBoundMethodInfo2.Invoke(viewResponse, parametersInDifferentNumber));
        }
예제 #2
0
        public void TestUserViewXmlGetAttributes()
        {
            string xml =
                @"<roar tick=""135595331857"">
				<user>
					<view status=""ok"">
						<attribute type=""special"" ikey=""id"" value=""635902077904630318""/>
						<attribute type=""special"" ikey=""xp"" value=""16807"" level_start=""5"" next_level=""7""/>
						<attribute ikey=""energy"" label=""Energy"" value=""10"" type=""resource"" min=""2"" max=""10"" regen_amount=""1"" regen_every=""18000"" next_regen=""135595635357""/>
						<attribute name=""status"" value=""No current status update available"" type=""custom""/>
					<regen_scripts/>
					</view>
				</user>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.User.View view_parser = new Roar.DataConversion.Responses.User.View();
            ViewResponse response = view_parser.Build(nn);

            Assert.IsNotNull(response.attributes);
            Assert.AreEqual(response.attributes.Count, 4);
            Assert.AreEqual(response.attributes[0].type, "special");
            Assert.AreEqual(response.attributes[0].ikey, "id");
            Assert.AreEqual(response.attributes[0].value, "635902077904630318");
            Assert.AreEqual(response.attributes[1].level_start, "5");
            Assert.AreEqual(response.attributes[1].next_level, "7");
            Assert.AreEqual(response.attributes[2].label, "Energy");
            Assert.AreEqual(response.attributes[2].min, "2");
            Assert.AreEqual(response.attributes[2].max, "10");
            Assert.AreEqual(response.attributes[2].regen_amount, "1");
            Assert.AreEqual(response.attributes[2].regen_every, "18000");
            Assert.AreEqual(response.attributes[2].next_regen, "135595635357");
            Assert.AreEqual(response.attributes[3].name, "status");
        }
예제 #3
0
        public IHttpResponse Index()
        {
            var response = new ViewResponse(HttpStatusCode.OK, new HomeView());

            response.AddCookie(new HttpCookie("lang", "en"));

            return(response);
        }
예제 #4
0
        public IHttpResponse User(IHttpRequest req)
        {
            var name = req.UrlParameters["name"];

            var response = new ViewResponse(HttpStatusCode.Ok, new UserView(name));

            return(response);
        }
예제 #5
0
        public IHttpResponse Login()//Get
        {
            var result = File.ReadAllText(@"../../../Application\Resources\loginGet.html");

            var response = new ViewResponse(HttpStatusCode.Ok, new CalculatorView(result));

            return(response);
        }
예제 #6
0
        public IHttpResponse Index()
        {
            var response = new ViewResponse(System.Net.HttpStatusCode.OK, new IndexView());

            response.Cookies.Add(new HttpCookie("lang", "en"));

            return(response);
        }
예제 #7
0
        public IHttpResponse Index()
        {
            var response = new ViewResponse(HttpStatusCode.Ok, new IndexView());

            response.Cookies.Add("lang", "en");

            return(response);
        }
예제 #8
0
        private ViewResponse GetFormAndData(Page page, int id)
        {
            ViewResponse viewResponse = new ViewResponse(page, id, _formAppService, _customerAppService);
            var          x            = viewResponse.Form;
            var          y            = viewResponse.Data;

            return(viewResponse);
        }
예제 #9
0
        // GET /about
        public IHttpResponse About()
        {
            ViewResponse response = new ViewResponse(HttpStatusCode.OK, new AboutView());

            response.Cookies.Add(new HttpCookie("lang", "en"));

            return(response);
        }
예제 #10
0
        // Get /
        public IHttpResponse Index()
        {
            IHttpResponse httpResponse = new ViewResponse(HttpStatusCode.Ok, new IndexView());

            httpResponse.Cookies.AddCookie(new HttpCookie("lang", "en"));

            return(httpResponse);
        }
예제 #11
0
        public IHttpResponse Index()
        {
            var result = new ViewResponse(HttpStatusCode.Ok, new IndexView());

            result.Cookies.Add(new HttpCookie("lang", "en"));

            return(result);
        }
예제 #12
0
        public void ViewResponse_Class_All_Properties_Getter_Settter_Test()
        {
            // Arrange
            var viewResponse = new ViewResponse();

            // Assert
            viewResponse.Master.ShouldBeNull();
        }
예제 #13
0
        public IHttpResponse Index()
        {
            var response = new ViewResponse(HttpStatusCode.Ok, new HomeIndexView());

            response.Cookies.Add(new HttpCookie("lang", "en")); //8 COOCIES


            return(response);
        }
예제 #14
0
        protected void View(object model)
        {
            TempData.EventHandled = true;
            var response = new ViewResponse();

            response.Execute(model, controllerContext);

            viewModel.ClearModelState();
        }
예제 #15
0
		public IHttpResponse Index(IHttpRequest req)
		{
			var response = new ViewResponse(HttpStatusCode.OK, new HomeIndexView());

			

			
			return response;
		}
예제 #16
0
        public void ViewResponse_Class_Invalid_Property_MasterNotPresent_Access_Using_Reflexion_Doesnt_Throw_Exception_Test()
        {
            // Arrange
            const string propertyNameMaster = "MasterNotPresent";
            var          viewResponse       = new ViewResponse();

            // Act , Assert
            Should.NotThrow(action: () => viewResponse.GetType().GetProperty(propertyNameMaster));
        }
예제 #17
0
        public IHttpResponse UserWithId(IHttpRequest req)
        {
            var name = req.UrlParameters["name"];
            var id   = int.Parse(req.UrlParameters["id"]);

            var response = new ViewResponse(HttpStatusCode.Ok, new UserViewAndId(name, id));

            return(response);
        }
예제 #18
0
        public IHttpResponse Details(IHttpRequest req)
        {
            var name = req.UrlParameters["name"];

            this.ViewData["<!--Replace-->"] = $"<div>Hello, {name}!</div>";

            var response = new ViewResponse(HttpStatusCode.Ok, new HtmlView(@"details", this.ViewData));

            return(response);
        }
예제 #19
0
        public IHttpResponse Calculator()// Get
        {
            var result = File.ReadAllText(@"../../../Application\Resources\calculator.html");

            result = result.Replace($"{{{{{{{"results"}}}}}}}", "0"); //default value

            var response = new ViewResponse(HttpStatusCode.Ok, new CalculatorView(result));

            return(response);
        }
        public IHttpResponse Cart(IHttpRequest request)
        {
            if (!CheckIfLoggedIn(request))
            {
                return(new RedirectResponse("/login"));
            }

            var result = new ViewResponse(HttpStatusCode.Ok, new CartView());

            return(result);
        }
예제 #21
0
        public IHttpResponse Login(string username, string password) //Post
        {
            var result = File.ReadAllText(@"../../../Application\Resources\loginPost.html");

            result = result.Replace($"{{{{{{{"username"}}}}}}}", username);
            result = result.Replace($"{{{{{{{"password"}}}}}}}", password);

            var response = new ViewResponse(HttpStatusCode.Ok, new CalculatorView(result));

            return(response);
        }
예제 #22
0
        public ActionResult PdfViewer(string Doc)
        {
            var            path           = Path.Combine(Server.MapPath("~/Content/Uploads"), Doc);
            ViewerSettings viewerSettings = new ViewerSettings();

            viewerSettings.VisibleFileOperationControls.Open = true;
            ViewResponse viewResponse = MvcApplication.StarDocs.Viewer.CreateView(
                new FileObject(path), null, viewerSettings);

            return(new RedirectResult(viewResponse.Url));
        }
        // GET: AttachmentP
        public ActionResult Display(string attachment)
        {
            //create viewer for document on server
            string         file           = @"C:/Users/Nader/Documents/GitHub/Map2018PI/Map2018IConsult/ProjetPiMap/UploadAttachment/" + attachment;
            ViewerSettings viewerSettings = new ViewerSettings();

            viewerSettings.VisibleFileOperationControls.Open = true;
            ViewResponse viwerResponse = MvcApplication.starDocs.Viewer.CreateView(
                new FileObject(file), null, viewerSettings);

            return(new RedirectResult(viwerResponse.Url));
        }
예제 #24
0
        public IHttpResponse FileViewResponse(string fileName)
        {
            var layoutHtml = File.ReadAllText($@"../../../ByTheCakeApp\Resources\layout.html");

            var fileHtml = File.ReadAllText($@"../../../ByTheCakeApp\Resources\{fileName}.html");

            var result = layoutHtml.Replace("{{{content}}}", fileHtml);

            var response = new ViewResponse(HttpStatusCode.Ok, new FileView(result));

            return(response);
        }
예제 #25
0
        public void TestItemsViewXmlParseMechanics()
        {
            string xml =
                @"<roar tick=""135536803344"">
				<items>
					<view status=""ok"">
						<item>
							<stats>
								<regen_stat_limited ikey=""premium_currency"" value=""345"" repeat=""12"" times_used=""4""/>
							</stats>
							<properties>
								<property ikey=""mariner"" value=""543""/>
							</properties>
							<tags>
								<tag value=""magicitem""/>
							</tags>
							<price>
								<grant_item ikey=""talisman""/>
							</price>
						</item>
					</view>
				</items>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);

            Mockery mockery = new Mockery();

            Roar.DataConversion.IXCRMParser    ixcrm_parser   = mockery.NewMock <Roar.DataConversion.IXCRMParser>();
            List <Roar.DomainObjects.ItemStat> item_stat_list = new List <Roar.DomainObjects.ItemStat>();
            List <Roar.DomainObjects.Modifier> modifier_list  = new List <Roar.DomainObjects.Modifier>();
            List <string> tag_list = new List <string>();

            Roar.DataConversion.Responses.Items.View items_view_response_parser = new Roar.DataConversion.Responses.Items.View();
            items_view_response_parser.ixcrm_parser = ixcrm_parser;

            System.Xml.XmlNode stat_node = nn.SelectSingleNode("./items/view/item/stats");
            Expect.Once.On(ixcrm_parser).Method("ParseItemStatList").With(stat_node).Will(Return.Value(item_stat_list));
            System.Xml.XmlNode modifiers_node = nn.SelectSingleNode("./items/view/item/price");
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(modifiers_node).Will(Return.Value(modifier_list));
            System.Xml.XmlNode tag_node = nn.SelectSingleNode("./items/view/item/tags");
            Expect.Once.On(ixcrm_parser).Method("ParseTagList").With(tag_node).Will(Return.Value(tag_list));

            ViewResponse response = items_view_response_parser.Build(nn);

            mockery.VerifyAllExpectationsHaveBeenMet();

            Assert.IsNotNull(response.items);
            Assert.AreEqual(response.items.Count, 1);
            Assert.AreEqual(response.items[0].stats, item_stat_list);
            Assert.AreEqual(response.items[0].price, modifier_list);
            Assert.AreEqual(response.items[0].tags, tag_list);
        }
예제 #26
0
        // GET /sessionTest.html
        public IHttpResponse SessionTest(IHttpRequest request)
        {
            var session = request.Session;

            if (session.Get("saved_date") == null)
            {
                session.Add("saved_date", DateTime.UtcNow);
            }

            var response = new ViewResponse(HttpStatusCode.Ok, new SessionTestView(session.Get <DateTime>("saved_date")));

            return(response);
        }
예제 #27
0
        public IActionResult GetMovieCount(int order = (int)MovieField.count, bool isAscending = true)
        {
            var ret = _business.FindMovieCount((MovieField)order, isAscending);

            if (ret == null)
            {
                return(NotFound());
            }
            ViewResponse <_vw_mc_ator> vr = new ViewResponse <_vw_mc_ator>();

            vr.server_response = ret;
            return(Ok(vr));
        }
예제 #28
0
        public ActionResult ReadBook()
        {
            string         file           = @"C:\Work\TopicReview.pdf";
            FileObject     read_file      = new FileObject(file);
            ViewerSettings viewerSettings = new ViewerSettings();

            viewerSettings.VisibleFileOperationControls.Open = true;

            ViewResponse viewResponse = MvcApplication.starDocs.Viewer.CreateView(
                read_file, null, viewerSettings);

            //Redirect
            return(new RedirectResult(viewResponse.Url));
        }
        public IHttpResponse Success(IHttpRequest request)
        {
            if (!CheckIfLoggedIn(request))
            {
                return(new RedirectResponse("/login"));
            }

            System.IO.File.WriteAllText("./Application/Resourses/products.csv", "");


            var result = new ViewResponse(HttpStatusCode.Ok, new SuccessView());

            return(result);
        }
예제 #30
0
        public IHttpResponse SessionTest(IHttpRequest req)
        {
            IHttpSession session = req.Session;

            const string sessionDateKey = "saved_date";

            if (session.Get(sessionDateKey) == null)
            {
                session.Add(sessionDateKey, DateTime.UtcNow);
            }
            var response = new ViewResponse(HttpStatusCode.OK, new SessionTestView(session.Get <DateTime>(sessionDateKey)));

            return(response);
        }