コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }