Ejemplo n.º 1
0
        public void BindModel_InvalType_TestAsync()
        {
            var binder = new ObjectIdBinder();
            var result = binder.BindModelAsync(fContext);

            Assert.True(result.IsCompleted);
        }
Ejemplo n.º 2
0
        public void BindModel_Success_NoneResult_TestAsync()
        {
            string modelName = "model";

            fContext.ModelName.Returns(modelName);
            fContext.ModelType.Returns(typeof(ObjectId));
            fValueProvider.GetValue(Arg.Is(modelName)).Returns(ValueProviderResult.None);

            var binder = new ObjectIdBinder();
            var result = binder.BindModelAsync(fContext);

            Assert.True(result.IsCompleted);
        }
Ejemplo n.º 3
0
        public async Task BindModel_Error_TestAsync()
        {
            var    id        = "aaaa";
            string modelName = "model";

            fContext.ModelName.Returns(modelName);
            fContext.ModelType.Returns(typeof(ObjectId));
            fValueProvider.GetValue(Arg.Is(modelName)).Returns(new ValueProviderResult(id.ToString()));
            fContext.ModelState = new ModelStateDictionary();

            var binder = new ObjectIdBinder();
            await binder.BindModelAsync(fContext);

            Assert.Single(fContext.ModelState);
        }
Ejemplo n.º 4
0
        public async Task BindModel_Success_IdResult_TestAsync()
        {
            var    id        = ObjectId.GenerateNewId();
            string modelName = "model";

            fContext.ModelName.Returns(modelName);
            fContext.ModelType.Returns(typeof(ObjectId));
            fValueProvider.GetValue(Arg.Is(modelName)).Returns(new ValueProviderResult(id.ToString()));
            fContext.ModelState = new ModelStateDictionary();

            var binder = new ObjectIdBinder();
            await binder.BindModelAsync(fContext);

            Assert.Equal(id, fContext.Result.Model);
        }