public async void new_should_redirect_if_model_is_valid()
        {
            //arrange
            var validModel = new UserModel {
                Name = "test name", Email = "*****@*****.**", Password = "******"
            };

            var userService = new Mock <IUserService>();

            userService.Setup(x => x.Create(It.IsAny <UserModel>(), SetLocaleRole.Developer.Value)).Returns(() => Task.FromResult <int?>(1));

            var formsAuthenticationService = new Mock <IFormsAuthenticationService>();

            formsAuthenticationService.Setup(x => x.SignIn(string.Format("{0}|{1}|{2}", 1, validModel.Name, validModel.Email), true));

            //act
            var sut = new UserControllerBuilder().WithUserService(userService.Object)
                      .WithFormsAuthenticationService(formsAuthenticationService.Object)
                      .Build();
            var view = await sut.New(validModel);

            //assert
            Assert.NotNull(view);
            Assert.AreEqual(((RedirectResult)view).Url, "/user/apps");
            userService.Verify(x => x.Create(It.IsAny <UserModel>(), SetLocaleRole.Developer.Value), Times.Once);

            sut.AssertPostAndAntiForgeryTokenAttribute("New", new[] { typeof(UserModel) });
            sut.AssertAllowAnonymousAttribute("New", new[] { typeof(UserModel) });
        }
        public void new_should_return_with_user_model()
        {
            //act
            var sut = new UserControllerBuilder().Build();

            var view = sut.New() as ViewResult;

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

            Assert.NotNull(model);
            Assert.IsAssignableFrom(typeof(UserModel), model);

            sut.AssertGetAttribute("New");
            sut.AssertAllowAnonymousAttribute("New");
        }
        public async void new_should_return_with_user_model_if_model_is_invalid()
        {
            //arrange
            var invalidModel = new UserModel {
                Name = "test name"
            };

            //act
            var sut  = new UserControllerBuilder().Build();
            var view = await sut.New(invalidModel) as ViewResult;

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

            Assert.NotNull(model);
            Assert.IsAssignableFrom(typeof(UserModel), model);

            sut.AssertPostAndAntiForgeryTokenAttribute("New", new[] { typeof(UserModel) });
            sut.AssertAllowAnonymousAttribute("New", new[] { typeof(UserModel) });
        }