public void CanFetchWithEmptyGuid()
        {
            var tag = new Tag
            {
                Id   = Guid.Empty,
                Name = "TopMovie"
            };

            tag.Create();

            var fetcher = new ARFetcher(new DefaultConverter());

            var parameter = typeof(MyController).GetMethod("MyAction3").GetParameters()[0];

            var attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];

            var customActionParameters = new Dictionary <string, object>();

            customActionParameters["id"] = Guid.Empty;

            var record = (Tag)fetcher.FetchActiveRecord(
                parameter, attribute, new StubRequest(), customActionParameters);

            Assert.AreEqual(tag.Id, record.Id);
        }
Beispiel #2
0
        public virtual object Bind(IEngineContext context, IController controller, IControllerContext controllerContext, ParameterInfo parameterInfo)
        {
            EnsureBinderExists();
            var fetcher = new ARFetcher(binder.Converter);

            return(fetcher.FetchActiveRecord(parameterInfo, this, context.Request.Params, controllerContext.CustomActionParameters));
        }
Beispiel #3
0
		public void CanGetItemByIdFromActionParams()
		{
			ARFetcher fetcher = new ARFetcher(new DefaultConverter());
			ParameterInfo parameter = typeof(MyController).GetMethod("MyAction").GetParameters()[0];
			ARFetchAttribute attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
			Dictionary<string, object> customActionParameters = new Dictionary<string, object>();
			customActionParameters["id"] = account1.Id.ToString();
			Account record = (Account)fetcher.FetchActiveRecord(
				parameter, attribute, new StubRequest(), customActionParameters);
			Assert.AreEqual(account1.Id, record.Id);
		}
Beispiel #4
0
		public void CanGetItemByIdFromRequest_UsingArray()
		{
			ARFetcher fetcher = new ARFetcher(new DefaultConverter());
			ParameterInfo parameter = typeof(MyController).GetMethod("MyAction2").GetParameters()[0];
			ARFetchAttribute attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
			StubRequest request = new StubRequest();
			request.Params.Add("id", account1.Id.ToString());
			request.Params.Add("id", account2.Id.ToString());
			Account[] records = (Account[])fetcher.FetchActiveRecord(
				parameter, attribute, request, new Dictionary<string, object>());
			Assert.AreEqual(account1.Id, records[0].Id);
			Assert.AreEqual(account2.Id, records[1].Id);
		}
        public void CanGetItemByIdFromActionParams()
        {
            var fetcher   = new ARFetcher(new DefaultConverter());
            var parameter = typeof(MyController).GetMethod("MyAction").GetParameters()[0];
            var attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
            var customActionParameters = new Dictionary <string, object>();

            customActionParameters["id"] = account1.Id.ToString();
            var record = (Account)fetcher.FetchActiveRecord(
                parameter, attribute, new StubRequest(), customActionParameters);

            Assert.AreEqual(account1.Id, record.Id);
        }
        public void CanGetItemByIdFromActionParams_UsingArray()
        {
            var fetcher   = new ARFetcher(new DefaultConverter());
            var parameter = typeof(MyController).GetMethod("MyAction2").GetParameters()[0];
            var attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
            var customActionParameters = new Dictionary <string, object>
            {
                { "id", new[] { account1.Id.ToString(), account2.Id.ToString() } }
            };
            var records = (Account[])fetcher.FetchActiveRecord(
                parameter, attribute, new StubRequest(), customActionParameters);

            Assert.AreEqual(account1.Id, records[0].Id);
            Assert.AreEqual(account2.Id, records[1].Id);
        }
		public void CanGetItemByIdFromActionParams_UsingArray()
		{
			var fetcher = new ARFetcher(new DefaultConverter());
			var parameter = typeof(MyController).GetMethod("MyAction2").GetParameters()[0];
			var attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
			var customActionParameters = new Dictionary<string, object>
			{
				{ "id", new[] { account1.Id.ToString(), account2.Id.ToString() } }
			};
			var records = (Account[])fetcher.FetchActiveRecord(
				parameter, attribute, new StubRequest(), customActionParameters);
		
			Assert.AreEqual(account1.Id, records[0].Id);
			Assert.AreEqual(account2.Id, records[1].Id);
		}
		public void CanFetchWithEmptyGuid()
		{
			Tag tag = new Tag() { Id = Guid.Empty, Name = "TopMovie" };
			tag.Create();
			
			ARFetcher fetcher = new ARFetcher(new DefaultConverter());
			
			ParameterInfo parameter = typeof(MyController).GetMethod("MyAction3").GetParameters()[0];
			
			ARFetchAttribute attribute = (ARFetchAttribute)parameter.GetCustomAttributes(typeof(ARFetchAttribute), true)[0];
			
			Dictionary<string, object> customActionParameters = new Dictionary<string, object>();
			customActionParameters["id"] = Guid.Empty;

			Tag record = (Tag)fetcher.FetchActiveRecord(
				parameter, attribute, new StubRequest(), customActionParameters);
			
			Assert.AreEqual(tag.Id, record.Id);
		}