Ejemplo n.º 1
0
        public void TypeCannotBeResolvedFromParent_CreatesUnresolvedType()
        {
            // Arrange
            var binder = new UserTypeBinder();
            var field  = Substitute.For <IField>();

            field.ResolveType(default).ReturnsForAnyArgs((INamedTypeSymbol)null);
        // GET: UserTypeModels
        public ActionResult Index()
        {
            UserTypeBinder userBinder = new UserTypeBinder();
            ICollection <UserTypeModel> userTypeModelList = userBinder.Bind(db.UserType.ToList());

            return(View(userTypeModelList));
        }
        public ActionResult Create([Bind(Include = "Id,UserTypeCode")] UserTypeModel userTypeModel)
        {
            if (ModelState.IsValid)
            {
                UserTypeBinder userTypeBinder = new UserTypeBinder();
                UserType       userType       = userTypeBinder.Bind(userTypeModel);
                db.UserType.Add(userType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userTypeModel));
        }
Ejemplo n.º 4
0
        public void TypeCanBeResolvedFromParent_ResolvesType()
        {
            // Arrange
            var binder       = new UserTypeBinder();
            var resolvedType = Substitute.For <INamedTypeSymbol>();
            var field        = Substitute.For <IField>();

            field.ResolveType("UserType").Returns(resolvedType);

            var node = ParserInput
                       .FromString("UserType")
                       .ParseInput(parser => parser.userType());

            // Act
            var result = binder.Bind <UserType>(node, field);

            // Assert
            Assert.Same(resolvedType, result.Definition);
        }