Ejemplo n.º 1
0
        public void TestView(AuthorViewModel model, string test)
        {
            _init();
            AuthorController controler = new AuthorController(_service);

            controler.New(model).GetAwaiter().GetResult();
            var r = controler.Vizualise(1) as PartialViewResult;

            Assert.IsTrue((r.Model as AuthorViewModel) != null, $"Erro no Teste: {test}");
        }
Ejemplo n.º 2
0
        public void TestListAll(ICollection <AuthorViewModel> model, string search, int page, string test, int result)
        {
            _init();
            AuthorController controler = new AuthorController(_service);

            foreach (var item in model)
            {
                controler.New(item).GetAwaiter().GetResult();
            }
            var r      = controler.ListAll(search, page) as PartialViewResult;
            var _model = (r.Model as AuthorPagination);

            Assert.IsTrue((r.Model as AuthorPagination).Author.Dados.Count == result, $"Erro no Teste: {test}");
        }
Ejemplo n.º 3
0
        public void TestUpdate(AuthorViewModel model, string name, string test, string result)
        {
            _init();
            AuthorController controler = new AuthorController(_service);

            controler.New(model).GetAwaiter().GetResult();
            var r      = controler.Vizualise(1) as PartialViewResult;
            var _model = (r.Model as AuthorViewModel);

            _model.Name = name;
            controler.Update(_model).GetAwaiter().GetResult();
            r      = controler.Vizualise(1) as PartialViewResult;
            _model = (r.Model as AuthorViewModel);
            Assert.IsTrue(_model.Name == result, $"Erro no Teste: {test}");
        }
Ejemplo n.º 4
0
        public void TestDelete(AuthorViewModel model, int id, string test)
        {
            _init();
            AuthorController controler = new AuthorController(_service);

            controler.New(model).GetAwaiter().GetResult();
            controler.Delete(id).GetAwaiter().GetResult();
            try
            {
                var r = controler.Vizualise(1) as PartialViewResult;
                Assert.Fail($"Erro no Teste: {test}");
            }
            catch (Exception)
            {
                Assert.Pass();
            }
        }