Пример #1
0
        public HttpResponseMessage Put(int id, Agent agent)
        {
            var successAPIResult = new SuccessAPIResult()
            {
                Usage = "HttpPut:~/api/Agent/{id} with Agent json in body"
            };

            successAPIResult.Successful = AgentBusinessLayer.UpdateAgent(id, agent);

            if (!successAPIResult.Successful)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, successAPIResult));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, successAPIResult));
        }
Пример #2
0
        public HttpResponseMessage Get(int id)
        {
            var agentAPIResult = new AgentAPIResult()
            {
                Usage = "HttpGet:~/api/Agent/{id} or {args} can be on querystring, {args?} are optional"
            };

            agentAPIResult.Agent = AgentBusinessLayer.GetAgent(id);

            if (agentAPIResult.Agent == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, agentAPIResult));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, agentAPIResult));
        }
Пример #3
0
        protected void Application_Start()
        {
            var initDB = false;

            GlobalConfiguration.Configure(WebApiConfig.Register);

            CustomerBusinessLayer.Register(new DBLayer());
            AgentBusinessLayer.Register(new DBLayer());

            bool.TryParse(ConfigurationManager.AppSettings["InitDB"], out initDB);

            if (initDB)
            {
                InitDB();
            }
        }
Пример #4
0
 public void WillCallDBLayerOnceWhenCreate()
 {
     AgentBusinessLayer.CreateAgent(new Agent());
     mockDBLayer.Verify(m => m.CreateEntity <Agent>(It.IsAny <Agent>()), Times.Once);
 }
Пример #5
0
 public void WillCallDBLayerOnceWhenGetAll()
 {
     AgentBusinessLayer.GetAgents(1, 1);
     mockDBLayer.Verify(m => m.FindAllEnties <Agent>(It.IsAny <int>(), It.IsAny <int>()), Times.Once);
 }
Пример #6
0
 public void WillCallDBLayerOnceWhenUpdate()
 {
     AgentBusinessLayer.UpdateAgent(1, new Agent());
     mockDBLayer.Verify(m => m.UpdateEntity <Agent>(It.IsAny <Agent>(), It.IsAny <int>()), Times.Once);
 }
Пример #7
0
 public void WillCallDBLayerOnceWhenGetById()
 {
     AgentBusinessLayer.GetAgent(1);
     mockDBLayer.Verify(m => m.FindEntity <Agent>(It.IsAny <int>()), Times.Once);
 }
Пример #8
0
 public void WillThrowExpectedExceptionWhenRegisteringNullDBLayer()
 {
     AgentBusinessLayer.Register(null);
 }
Пример #9
0
 public void Init()
 {
     mockDBLayer = new Mock <IDBLayer>();
     AgentBusinessLayer.Register(mockDBLayer.Object);
 }