public void Groot_ReturnsStatusOK() { // Arrange var rocketServiceMock = new Mock <RocketService>(); var controller = new GuardianController(rocketServiceMock.Object); // Act var result = (ObjectResult)controller.Groot("message"); // Assert Assert.Equal(200, result.StatusCode); }
protected void BindProductList() { try { Guardian sysmgr = new GuardianController(); List <GuardianController> info = sysmgr.Guardian_List(); } catch (Exception ex) { } }
public void Youndu_GetEndpointWithAllParametersReturnsStatusOK() { //Arrange var rocketServiceMock = new Mock <RocketService>(); var controller = new GuardianController(rocketServiceMock.Object); //Act var result = (ObjectResult)controller.YondosArrow(100, 10); //Assert Assert.Equal(200, result.StatusCode); }
// Method name: <tested method name>_<input type>_<return type> // Example: RocketFill_ValidInput_ReturnsOk() public void Rocket_ReturnsOk() { // Arrange var rocketServiceMock = new Mock <RocketService>(); rocketServiceMock.Setup(r => r.GetRocket()).Returns(GetFullRocket()); var controller = new GuardianController(rocketServiceMock.Object); // Act var result = (ObjectResult)controller.Rocket(); // Assert Assert.Equal(200, result.StatusCode); }
public void Youndu_GetEndpointWithNoCompleteParametersReturnsStatusNotOk() { //Arrange var expectedError = new ErrorObj("Missing query parameter."); var rocketServiceMock = new Mock <RocketService>(); var controller = new GuardianController(rocketServiceMock.Object); double?distance = null, time = null; //Act var result = (ObjectResult)controller.YondosArrow(distance, time); // Assert Assert.Equal <ErrorObj>(expectedError, (ErrorObj)result.Value); Assert.Equal(400, result.StatusCode); }
public void Groot_ReturnsErrorMessage() { //Arrange var expectedError = new ErrorObj("I am Groot!"); string someMessage = null; var rocketServiceMock = new Mock <RocketService>(); var controller = new GuardianController(rocketServiceMock.Object); //Act var result = (ObjectResult)controller.Groot(someMessage); //Assert Assert.Equal <ErrorObj>(expectedError, (ErrorObj)result.Value); Assert.Equal(400, result.StatusCode); // Asser.Equal(expected, actual) }
protected void BindGuardianList() { try { GuardianController sysmgr = new GuardianController(); List <Guardian> info = null; info = sysmgr.List(); info.Sort((x, y) => x.GuardianID.CompareTo(y.GuardianID)); GuardianList.DataSource = info; GuardianList.DataTextField = nameof(Guardian.FullName); GuardianList.DataValueField = nameof(Guardian.GuardianID); GuardianList.DataBind(); GuardianList.Items.Insert(0, "select..."); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } }
protected void BindGuardianList() { try { GuardianController guardianController = new GuardianController(); List <Guardian> guardianInfo = null; guardianInfo = guardianController.Guardian_List(); guardianInfo.Sort((x, y) => x.FullName.CompareTo(y.FullName)); GuardianList.DataSource = guardianInfo; GuardianList.DataTextField = nameof(Guardian.FullName); GuardianList.DataValueField = nameof(Guardian.GuardianID); GuardianList.DataBind(); GuardianList.Items.Insert(0, "Select a guardian..."); } catch (Exception ex) { //Message.Visible = true; errorMessageList.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errorMessageList, "alert alert-danger"); } }
protected void BindGuardianList() { try { GuardianController sysmgr = new GuardianController(); List <Guardian> info = null; info = sysmgr.List(); info.Sort((x, y) => x.Name.CompareTo(y.Name)); GuardianList.DataSource = info; GuardianList.DataTextField = nameof(Guardian.Name); GuardianList.DataValueField = nameof(Guardian.GuardianID); GuardianList.DataBind(); ListItem myitem = new ListItem(); myitem.Value = "0"; myitem.Text = "select..."; GuardianList.Items.Insert(0, myitem); } catch (Exception ex) { ShowMessage(GetInnerException(ex).ToString(), "alert alert-danger"); } }
public async Task WhoAreYou() { var controller = new GuardianController(); var result = await controller.Groot(); }