Example #1
0
        public void AllEvents_CheckResultIsView()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext())
                using (var eventController = new EventController(context, null, _logger, null))
                {
                    // Act
                    var vr = eventController.AllEvents();

                    // Assert
                    Assert.IsType <ViewResult>(vr.Result);
                }
        }
Example #2
0
        public void AllEvents_CheckIsModelCountResult()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext())
                using (var eventController = new EventController(context, null, _logger, null))
                {
                    // Act
                    var vr    = ((eventController.AllEvents()).Result as ViewResult);
                    var model = vr.Model as ICollection <AllEventViewModel>;

                    // Assert
                    Assert.Equal <int>(2, model.Count);
                }
        }
Example #3
0
        public void AllEvents_CheckIsTypeModelResult()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext())
                using (var eventController = new EventController(context, null, _logger, null))
                {
                    // Act
                    var vr    = ((eventController.AllEvents()).Result as ViewResult);
                    var model = vr.Model;

                    // Assert
                    Assert.IsAssignableFrom <IEnumerable <AllEventViewModel> >(model);
                }
        }
Example #4
0
        public void AllEvents_CheckModelResultNotNull()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext())
                using (var eventController = new EventController(context, null, _logger, null))
                {
                    // Act
                    var vr    = ((eventController.AllEvents()).Result as ViewResult);
                    var model = vr.Model;

                    // Assert
                    Assert.NotNull(model);
                }
        }
Example #5
0
        public void CreateEvent_CheckIfModelHasError()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext())
                using (var controller = new EventController(context, null, _logger, null))
                {
                    // Act
                    controller.ModelState.AddModelError("error", "some error");
                    var br = controller.CreateEvent(new CreateEventViewModel()).Result;

                    // Assert
                    Assert.IsType <BadRequestResult>(br);
                }
        }
Example #6
0
        public void AllEvents_CheckIfModelIsEmpty()
        {
            // Arrange
            using (var context = DbContextInitializer.GetContext(false))
                using (var controller = new EventController(context, null, _logger, null))
                {
                    // Act
                    var vr    = controller.AllEvents().Result as ViewResult;
                    var model = vr.Model as ICollection <AllEventViewModel>;

                    // Assert
                    Assert.IsType <ViewResult>(vr);
                    Assert.Equal <int>(0, model.Count);
                }
        }
Example #7
0
 public void CreateEvent_CheckIfNoUser()
 {
     try
     {
         // Arrange
         using (var context = DbContextInitializer.GetContext())
             using (var controller = new EventController(context, null, _logger, null))
             {
                 // Act
                 Assert.Throws <AggregateException>(() =>
                                                    controller.CreateEvent(new CreateEventViewModel()).Result);
             }
     }
     catch (AggregateException exception)
     {
         // Assert
         Assert.Equal("Unable to load current user ClaimTypes.NameIdentifier", exception.Message);
     }
 }