コード例 #1
0
 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));
 }
コード例 #2
0
ファイル: CrudTests.cs プロジェクト: aidancasey/Moksy
        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);
        }
コード例 #3
0
ファイル: CrudTests.cs プロジェクト: aidancasey/Moksy
        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);
        }
コード例 #4
0
ファイル: Proxy.cs プロジェクト: aidancasey/Moksy
        /// <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;
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 public void MustSpecifyNounFirstTo()
 {
     Simulation s = new Simulation();
     s.To("somewhere");
 }
コード例 #8
0
ファイル: SimulationFactory.cs プロジェクト: aidancasey/Moksy
 /// <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;
 }
コード例 #9
0
ファイル: SimulationFactory.cs プロジェクト: aidancasey/Moksy
 /// <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;
 }