예제 #1
0
        public void index_should_return()
        {
            // Act
            var controller = new AdminController(null, null, null);
            var view = controller.Index();

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Index");
        }
예제 #2
0
        public void new_translator_should_return_with_user_model()
        {
            // Act
            var controller = new AdminController(null, null, null);
            var view = controller.NewTranslator();
            var model = view.Model;

            // Assert
            Assert.NotNull(view);
            Assert.NotNull(model);
            Assert.IsAssignableFrom(typeof(UserModel), model);
            controller.AssertGetAttribute("NewTranslator");
        }
예제 #3
0
        public async void new_translator_should_return_with_app_model_if_model_is_invalid()
        {
            // Arrange
            var inValidModel = new UserModel { Name = "test name" };

            // Act
            var controller = new AdminController(null, null, null);
            var view = await controller.NewTranslator(inValidModel) as ViewResult;

            // Assert
            Assert.NotNull(view);
            Assert.NotNull(view.Model);
            var model = view.Model as UserModel;

            Assert.NotNull(model);

            controller.AssertPostAttribute("NewTranslator", new[] { typeof(UserModel) });
        }
예제 #4
0
        public async void new_translator_should_redirect_if_model_is_valid()
        {
            // Arrange
            var validModel = new UserModel { Name = "test name", Email = "*****@*****.**" };

            var userService = new Mock<IUserService>();
            userService.Setup(x => x.Create(It.IsAny<UserModel>(), SetLocaleRole.Translator.Value)).Returns(() => Task.FromResult<int?>(1));

            // Act
            var controller = new AdminController(userService.Object, null, null);
            var view = await controller.NewTranslator(validModel) as RedirectResult;

            // Assert
            Assert.NotNull(view);
            Assert.AreEqual(view.Url, "/admin/users");
            userService.Verify(x => x.Create(It.IsAny<UserModel>(), SetLocaleRole.Translator.Value), Times.Once);
            controller.AssertPostAttribute("NewTranslator", new[] { typeof(UserModel) });
        }
예제 #5
0
        public void admin_index_test()
        {
            // Arrange
            var authService = new Mock<IFormsAuthenticationService>();
            var demoService = new Mock<IDemoDataService>();

            //todo: mock https response

            // Act
            var controller = new AdminController(authService.Object, demoService.Object);
            var view = controller.NewTranslator();
            var view2 = controller.Users();
            var view3 = controller.Apps();

            demoService.Verify(x => x.GetAllApps(), Times.Once);
            demoService.Verify(x => x.GetAllUsers(), Times.Once);
            demoService.Verify(x => x.GetAUser(), Times.Once);
            // Assert
            Assert.NotNull(view);
            Assert.NotNull(view2);
            Assert.NotNull(view3);
        }
예제 #6
0
        public void users_should_return_with_app_model()
        {
            // Arrange           
            var userService = new Mock<IUserService>();

            // Act
            var controller = new AdminController(userService.Object, null, null);
            var view = controller.Users(1);

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Users");
            userService.Verify(x => x.GetAllByRoleId(1), Times.Once);

            view = controller.Users(8);     // Methodta id>0 && id<4 olduğu için iki ayrı kontrol yaptık.

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Users");
            userService.Verify(x => x.GetAll(), Times.Once);
        }
예제 #7
0
        public void apps_should_return_with_app_model()
        {
            // Arrange           
            var appService = new Mock<IAppService>();

            // Act
            var controller = new AdminController(null, null, appService.Object);
            var view = controller.Apps();

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Apps");
            appService.Verify(x => x.GetAll(), Times.Once);
        }