public void CanAddIfEndpointDoesNotExist() { Moksy.Storage.SimulationManager manager = new Storage.SimulationManager(); Simulation s = new Simulation(); s.Condition.SimulationConditionContent.Pattern = "/Pet"; Assert.IsTrue(manager.CanAdd(s, "/Pet", "Kind", "Dog", null)); }
public void CreateWithName() { Simulation s = new Simulation() { Name = "Trial1" }; var response = Proxy.Add(s); Assert.AreEqual(System.Net.HttpStatusCode.Created, response); var all = Proxy.GetAll(); Assert.AreEqual(1, all.Count); Assert.AreEqual("Trial1", all[0].Name); }
public void DeleteAll() { Simulation s = new Simulation() { Name = "Trial1" }; var response = Proxy.Add(s); response = Proxy.DeleteByName("*"); Assert.AreEqual(System.Net.HttpStatusCode.NoContent, response); var all = Proxy.GetAll(); Assert.AreEqual(0, all.Count); }
/// <summary> /// Add the given simulation to the running service. /// </summary> /// <param name="simulation">The simulation to add. Must not be null. </param> /// <returns>Created - the entry was added. Any other error indicates a failure. </returns> public HttpStatusCode Add(Simulation simulation) { if (null == simulation) throw new System.ArgumentNullException("simulation"); string path = string.Format("{0}", GetSimulationResource()); RestSharp.IRestClient client = new RestSharp.RestClient(Root); RestSharp.IRestRequest request = new RestSharp.RestRequest(path, RestSharp.Method.POST); request.AddParameter("application/json", JsonConvert.SerializeObject(simulation, JsonSerializerSettings), RestSharp.ParameterType.RequestBody); var response = client.Execute(request); return response.StatusCode; }
/// <summary> /// Determines if the path and headers match for this simulation. This is a helper method around the Simulation.Condition property. /// </summary> /// <param name="simulation"></param> /// <param name="content"></param> /// <param name="method"></param> /// <param name="path"></param> /// <param name="headers"></param> /// <returns></returns> public bool Matches(Simulation simulation, HttpContent content, System.Net.Http.HttpMethod method, string path, string query, IEnumerable<Header> headers) { if (null == simulation) return false; return Matches(simulation.Condition, content, method, path, query, headers); }
/// <summary> /// Determines if the path and headers match for this simulation. This is a helper method around the Simulation.Condition property. /// </summary> /// <param name="simulation"></param> /// <param name="method"></param> /// <param name="path"></param> /// <param name="headers"></param> /// <returns></returns> public bool Matches(Simulation simulation, System.Net.Http.HttpMethod method, string path, string query, IEnumerable<Header> headers) { return Matches(simulation, null, method, path, query, headers); }
public void MustSpecifyNounFirstTo() { Simulation s = new Simulation(); s.To("somewhere"); }
/// <summary> /// Create a new simulation. You will rarely use this method; instead, use one or more of the OnVerb calls. /// </summary> /// <returns></returns> public static Simulation New(string name) { var result = new Simulation() { Name = name }; return result; }
/// <summary> /// Create a new simulation. You will rarely use this method; instead, use one or more of the OnVerb calls. /// </summary> /// <returns></returns> public static Simulation New() { var result = new Simulation(); return result; }