public void Index_Test()
        {
            // Arrange
            var returnItems = new List <Foo>()
            {
                new Foo()
                {
                    Id = 1
                }, new Foo()
                {
                    Id = 2
                }
            };

            modelRepo.Expect(action => action.All).Return(returnItems.AsQueryable());

            // Act
            var result = controller.Index();

            // Assert
            Assert.That(result.Model, Is.InstanceOf <IEnumerable <Foo> >(), "TypeOf Model");
            var typedModel = (IEnumerable <Foo>)result.Model;

            Assert.That(typedModel.Count(), Is.EqualTo(2), "Model Items");
        }
Пример #2
0
        public void Test1Async()
        {
            var r   = _fooController.Index();
            var v   = r as OkObjectResult;
            var res = v.Value;


            Assert.AreEqual("1", res);
        }
        public void is_index_returns_iqueryable_foo_count_of_4()
        {
            //Arrange
            //Create the controller instance
            FooController fooController = new FooController(fooRepo);

            //Act
            var indexModel = (IQueryable <object>)fooController.Index().Model;

            //Assert
            Assert.AreEqual <int>(4, indexModel.Count());
        }
        public void is_index_returns_model_type_of_iqueryable_foo()
        {
            //Arrange
            //Create the controller instance
            FooController fooController = new FooController(fooRepo);

            //Act
            var indexModel = fooController.Index().Model;

            //Assert
            Assert.IsInstanceOfType(indexModel, typeof(IQueryable <Foo>));
        }