コード例 #1
0
 public ExecuteResult <WebsiteApiModel> Update(UpdateWebsiteApiModel webSite)
 {
     return(_webRequest.CreateRequest(ApiResource.Website.UPDATE)
            .JsonResponseHandler()
            .Execute()
            .Post <WebsiteApiModel>(webSite));
 }
コード例 #2
0
        public void website_should_be_update_website()
        {
            var testModel = new UpdateWebsiteApiModel
            {
                Name    = "bar.com",
                RootUrl = "http://bar.com"
            };

            var mockHttpRequest = new Mock <IHttpRequest>();

            var mockExecuter = new Mock <IExecuter>();

            mockExecuter.Setup(x => x.Post <WebsiteApiModel>(testModel))
            .Returns(new ExecuteResult <WebsiteApiModel>
            {
                Status = HttpStatusCode.OK,
                Data   = new WebsiteApiModel
                {
                    Id      = new Guid("faf48dcc-93fd-4b44-93e9-a2ff7de497c0"),
                    Name    = testModel.Name,
                    RootUrl = testModel.RootUrl
                }
            });


            mockHttpRequest.Setup(x => x.CreateRequest(ApiResource.Website.UPDATE)).Returns(mockHttpRequest.Object);
            mockHttpRequest.Setup(x => x.Execute()).Returns(mockExecuter.Object);

            var netsparkerClient = new NetsparkerRestClient(mockHttpRequest.Object);

            var result = netsparkerClient.WebSite()
                         .Update(testModel);

            Guid expected = new Guid("faf48dcc-93fd-4b44-93e9-a2ff7de497c0");
            Guid actual   = result.Data.Id;

            Assert.AreEqual(expected, actual);
        }