Exemplo n.º 1
0
 public HttpResponseMessage PostUserEvent(UserEvent userEvent)
 {
     var result = repository.Add(userEvent);
     var response = Request.CreateResponse(HttpStatusCode.Created, result);
     var uri = Url.Link("DefaultApi", new {controller = "UserEvents", id = result.Id});
     if (!String.IsNullOrEmpty(uri))
     {
         response.Headers.Location = new Uri(uri);
     }
     return response;
 }
 public UserEventControllerTest()
 {
     var request = new HttpRequestMessage();
     var config = new HttpConfiguration();
     userEvent = new UserEvent
         {
             Feature = "Moose",
             Id = Guid.NewGuid(),
             Type = "Tick",
             At = DateTime.Now
         };
     config.Routes.Add("DefaultApi", new HttpRoute("api/{controller}/{id}"));
     request.Properties["MS_HttpConfiguration"] = config;
     repository = new Mock<IUserEventRepository>(MockBehavior.Strict);
     controller = new UserEventsController(repository.Object) { Request = request };
 }
Exemplo n.º 3
0
 public UserEventTest()
 {
     userEvent = new UserEvent {Feature = "Moose", Type = "Tick", At = new DateTime(2013, 7, 18)};
 }
Exemplo n.º 4
0
 public UserEvent Add(UserEvent userEvent)
 {
     var result = context.UserEvents.Add(userEvent);
     context.SaveChanges();
     return result;
 }