public void RoomPricesCreate() { RoomPricesController controller = new RoomPricesController(); RoomPrice roomPrice = new RoomPrice(); roomPrice.RoomTypeId = 1; roomPrice.StartDate = new DateTime(2015, 9, 17); roomPrice.EndDate = new DateTime(2015, 9, 25); roomPrice.SpecialPrice = 250; roomPrice.RoomPriceId = 0; roomPrice.AccomodationId = 1; var result = controller.Create(roomPrice); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public void AccomodationsCreateInvalidInput() { RoomPricesController controller = new RoomPricesController(); RoomPrice roomPrice = new RoomPrice(); roomPrice.RoomTypeId = 1; roomPrice.StartDate = new DateTime(2015, 9, 17); roomPrice.EndDate = new DateTime(2015, 9, 25); roomPrice.SpecialPrice = -250; roomPrice.RoomPriceId = 0; roomPrice.AccomodationId = 1; var context = new ValidationContext(roomPrice, null, null); var results = new List<ValidationResult>(); TypeDescriptor.AddProviderTransparent(new AssociatedMetadataTypeTypeDescriptionProvider(typeof(RoomPrice), typeof(RoomPrice)), typeof(RoomPrice)); var isModelStateValid = Validator.TryValidateObject(roomPrice, context, results, true); Assert.AreEqual(false, isModelStateValid); }