public void PostPatientRegistration_ValidRequest_Returns_HttpStatusCode_Created() { // Arrange var businessServiceMock = new Mock <IBusinessService>(); businessServiceMock.Setup(service => service.RegisterPatient(PatientRegistrationInfoEntityTestData())).Returns(1); var controller = new PatientRegistrationController(businessServiceMock.Object); // Create the mock and set up the Link method, which is used to create the Location header. // The mock version returns a fixed string. string locationUrl = "http://location/"; var mockUrlHelper = new Mock <UrlHelper>(); mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(locationUrl); controller.Url = mockUrlHelper.Object; // Act var actionResult = controller.Post(PatientRegistrationInfoTestData()); // Assert var negResult = actionResult as CreatedNegotiatedContentResult <String>; Assert.IsNotNull(negResult); Assert.IsNotNull(negResult.Content); Assert.AreEqual(negResult.Content, "Patient is regiested"); Assert.AreEqual(negResult.Location, locationUrl); }
public PatientRegistration() { this.InitializeComponent(); controller = new PatientRegistrationController(); var uSStates = new USStates(); this.sex_ComboBox.ItemsSource = controller.Genders; this.sex_ComboBox.SelectedIndex = controller.SelectedIndex; this.state_ComboBox.ItemsSource = uSStates.States; this.state_ComboBox.SelectedIndex = 0; }