public void Post_Error() { // Arrange var context = new TestCaseContext(); var sut = new PingController( context.Logger, context.SessionManager); Mock.Get(context.SessionManager).Setup( m => m.PingSession(context.Session.Id)) .Throws(new Exception("message")); // Act var actionResult = sut.Post(context.Session.Id); // Assert Assert.NotNull(actionResult); var objectResult = actionResult.Result as ObjectResult; Assert.NotNull(objectResult); Assert.Equal(500, objectResult.StatusCode); var result = objectResult.Value as ApiResponse <EmptyPayload>; Assert.NotNull(result); Assert.False(result.Success); Assert.NotNull(result.Error); Assert.Null(result.Payload); }
public void Post_Success() { // Arrange var context = new TestCaseContext(); var sut = new PingController( context.Logger, context.SessionManager); // Act var actionResult = sut.Post(context.Session.Id); // Assert Assert.NotNull(actionResult); var objectResult = actionResult.Result as ObjectResult; Assert.NotNull(objectResult); Assert.Equal(200, objectResult.StatusCode); var result = objectResult.Value as ApiResponse <EmptyPayload>; Assert.NotNull(result); Assert.True(result.Success); Assert.Null(result.Error); var payload = result.Payload; Assert.Null(payload); Mock.Get(context.SessionManager).Verify( m => m.PingSession(context.Session.Id), Times.Once); }
public void Test1() { var controller = new PingController(_loggerMock.Object, _mapper); var payload = new PingRequest() { SomeId = "123" }; var response = controller.Post(payload); Assert.AreEqual(payload.SomeId, response.SomeId); }
public void PingPost() { //arrange _mokuserDetailLogic.Setup(a => a.FillUserData()); //act var pingController = new PingController(_mokuserDetailLogic.Object); pingController.Post(); //assert _mokuserDetailLogic.Verify(m => m.FillUserData(), Times.Once); }
public void TestPingVehicle() { // Arrange var pingViewModel = new PingViewModel { VehicleId = "YS2R4X20005399401" }; // Act var result = _pingController.Post(pingViewModel).Result; var okResult = result as OkObjectResult; // Assert Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); }