public void NonExistantIdResultsIn404() { var mock = CreateMock(); mock.Setup(x => x.GetCustomerApiKeyRuleById(1)).Returns((Model.CustomerApiKeyRule)null); var controller = new CustomerApiKeyRuleController(() => mock.Object) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; var ret = controller.Get(1); Assert.AreEqual(404, (int)ret.StatusCode); }
public void GetRule() { var obj = new Model.CustomerApiKeyRule { Id = 1, ApiKeyId = 11, Changed = DateTime.Now, ChangedBy = "Jitesh" }; var mock = CreateMock(); mock.Setup(x => x.GetCustomerApiKeyRuleById(1)).Returns(obj); var controller = new CustomerApiKeyRuleController(() => mock.Object) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; var ret = controller.Get(1); Assert.AreEqual(Newtonsoft.Json.JsonConvert.SerializeObject(obj), ret.Content.ReadAsStringAsync().Result); }