public void CreatePostShouldReturnViewWithTheSameModelWhenModelStateIsInvalid()
 => MyController <GamesController>
 .Instance()
 .Calling(c => c.Create(With.Default <CreateGameViewModel>()))
 .ShouldHave()
 .InvalidModelState()
 .AndAlso()
 .ShouldReturn()
 .View(result => result
       .WithModelOfType <CreateGameViewModel>()
       .Passing(game => game.DateAndStartTime == null));
예제 #2
0
 public void PostAddressAndPaymentShouldReturnViewWithInvalidPromoCode()
 {
     MyMvc
     .Controller <CheckoutController>()
     .WithHttpRequest(request => request
                      .WithFormField("PromoCode", "Invalid"))
     .Calling(c => c.AddressAndPayment(
                  With.No <MusicStoreContext>(),
                  With.Default <Order>(),
                  CancellationToken.None))
     .ShouldReturn()
     .View(With.Default <Order>());
 }
예제 #3
0
 public void PostLoginShouldHaveCorrectActionFilters()
 {
     MyMvc
     .Controller <AccountController>()
     .Calling(c => c.Login(
                  With.Default <LoginViewModel>(),
                  With.No <string>()))
     .ShouldHave()
     .ActionAttributes(attrs => attrs
                       .RestrictingForHttpMethod(HttpMethod.Post)
                       .AllowingAnonymousRequests()
                       .ValidatingAntiForgeryToken());
 }
예제 #4
0
 public void PostLoginShouldReturnDefaultViewWithInvalidModel()
 => MyMvc
 .Controller <AccountController>()
 .Calling(c => c.Login(
              With.Default <LoginViewModel>()))
 .ShouldHave()
 .ModelState(modelState => modelState
             .For <LoginViewModel>()
             .ContainingErrorFor(m => m.Email)
             .ContainingErrorFor(m => m.Password))
 .AndAlso()
 .ShouldReturn()
 .View();
 public void EditPostShouldReturnViewWithSameModelWhenInvalidModelState()
 => MyController <GamesController>
 .Instance(instance => instance
           .WithUser()
           .WithData(new Game
 {
     Id = 1,
     DateAndStartTime   = "TestDateAndStartTime 1",
     StadiumLocationUrl = "TestStadiumLocationUrl 1",
     Format             = "TestFormat 1",
 }))
 .Calling(c => c.Edit(With.Default <EditGameViewModel>()))
 .ShouldHave()
 .InvalidModelState()
 .AndAlso()
 .ShouldReturn()
 .View(With.Default <EditGameViewModel>());
 public void EditPostShouldReturnViewWithSameModelWhenInvalidModelState()
 => MyController <PhotoAlbumsController>
 .Instance(instance => instance
           .WithUser()
           .WithData(new PhotoAlbum
 {
     Id                = 1,
     Title             = "TestTitle 1",
     ThumbnailPhotoUrl = "TestThumbnailPhotoUrl 1",
     FacebookAlbumUrl  = "TestFacebookAlbumUrl 1",
     EventDate         = "TestEventDate 1",
 }))
 .Calling(c => c.Edit(With.Default <EditPhotoAlbumViewModel>()))
 .ShouldHave()
 .InvalidModelState()
 .AndAlso()
 .ShouldReturn()
 .View(With.Default <EditPhotoAlbumViewModel>());
예제 #7
0
 public void PostAddressAndPaymentShouldHaveValidAttributes()
 {
     MyMvc
     .Controller <CheckoutController>()
     .Calling(c => c.AddressAndPayment(
                  With.No <MusicStoreContext>(),
                  With.Default <Order>(),
                  CancellationToken.None))
     .ShouldHave()
     .ActionAttributes(attrs => attrs
                       .RestrictingForHttpMethod(HttpMethod.Post)
                       .ValidatingAntiForgeryToken())
     .AndAlso()
     .ShouldHave()
     .InvalidModelState()
     .AndAlso()
     .ShouldReturn()
     .View(With.Default <Order>());
 }
 public void GetShouldHaveCorrectAttributes()
 => MyController <CarAdsController>
 .Calling(c => c.Search(With.Default <SearchCarAdsQuery>()))
 .ShouldHave()
 .ActionAttributes(attr => attr
                   .RestrictingForHttpMethod(HttpMethod.Get));