Пример #1
0
        public async void TestCreate_InvalidRating_ShouldFail()
        {
            // Arrange
            RatingsController controller = new RatingsController(_context);

            InitializeRating();
            rating.GameId = 99;

            try
            {
                // Act
                var result = await controller.Create(rating.GameId, Convert.ToInt16(rating.Rate));

                // Assert
                Assert.IsType <ViewResult>(result);
                ViewResult viewResult = (ViewResult)result;
                Assert.NotNull(viewResult.ViewData.ModelState);
                Assert.NotEmpty(viewResult.ViewData.ModelState.Keys);

                foreach (string item in viewResult.ViewData.ModelState.Keys)
                {
                    Assert.Equal("", item);
                }
            }
            catch (Exception ex)
            {
                Assert.Equal("System.NullReferenceException", ex.GetType().ToString());
            }
        }
Пример #2
0
        public void TestRatingsControllerCreateName()
        {
            var          controller = new RatingsController();
            ActionResult result     = controller.Create() as ViewResultBase;
            string       r          = (result as ViewResult).ViewName;

            Assert.AreEqual("Create", r);
        }
Пример #3
0
            public void TestLocalsControllerCreateView()
            {
                var          controller = new RatingsController();
                ActionResult result     = controller.Create() as ViewResult;

                //Assert.AreEqual("Create", result.ViewName);
                Assert.IsInstanceOfType(result, typeof(ViewResult));
            }