示例#1
0
        public async void Update_NotFound()
        {
            TagsControllerMockFacade mock = new TagsControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiTagsResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(false);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiTagsRequestModel>())).Returns(Task.FromResult <UpdateResponse <ApiTagsResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiTagsResponseModel>(null));
            TagsController controller = new TagsController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiTagsModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Update(default(int), new ApiTagsRequestModel());

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
示例#2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string _tags   = txtTags.Text;
        int    _status = 0;

        if (chkStatus.Checked)
        {
            _status = 1;
        }
        else
        {
            _status = 0;
        }
        bool kt = false;

        if (!string.IsNullOrEmpty(Request.QueryString["ID"].ToString()))
        {
            kt = objTags.Update(Convert.ToInt32(Request.QueryString["ID"]), _tags);
        }
        else
        {
            int _tagID = objTags.Insert(_tags, DateTime.Now, _status);
            if (_tagID > 0)
            {
                kt = true;
            }
        }
        if (kt)
        {
            divMessage.InnerHtml = O2S_Message.Success("Hệ thống", " thực hiện thành công");
        }
        else
        {
            divMessage.InnerHtml = O2S_Message.Error("Hệ thống", " phát sinh lỗi");
        }
    }
        public void TagsControllerUpdate()
        {
            var result = _ctrl.Update(new TagToUpdate());

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }