You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/09/02 17:06:31 UTC

[08/10] usergrid-dotnet git commit: Initial commit of Usergrid .NET SDK into its own rep

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/ConnectionManagerTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/ConnectionManagerTests.cs b/Usergrid.Sdk.Tests/ConnectionManagerTests.cs
new file mode 100644
index 0000000..cbe536e
--- /dev/null
+++ b/Usergrid.Sdk.Tests/ConnectionManagerTests.cs
@@ -0,0 +1,240 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System.Collections.Generic;
+using System.Net;
+using NSubstitute;
+using NUnit.Framework;
+using RestSharp;
+using Usergrid.Sdk.Manager;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+
+namespace Usergrid.Sdk.Tests
+{
+    [TestFixture]
+    public class ConnectionManagerTests
+    {
+        [SetUp]
+        public void Setup()
+        {
+            _request = Substitute.For<IUsergridRequest>();
+            _connectionManager = new ConnectionManager(_request);
+        }
+
+        private IUsergridRequest _request;
+        private ConnectionManager _connectionManager;
+
+        [Test]
+        public void CreateConnectionShouldPostToCorrectEndpoint() {
+            var connection = new Connection
+                {
+                    ConnectorCollectionName = "users",
+                    ConnectorIdentifier = "userName",
+                    ConnecteeCollectionName = "devices",
+                    ConnecteeIdentifier = "deviceName",
+                    ConnectionName = "has"
+                };
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            _connectionManager.CreateConnection(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest(
+                    "/users/userName/has/devices/deviceName",
+                    Method.POST);
+        }
+
+        [Test]
+        public void CreateConnectionShouldThrowUsergridExceptionWhenBadResponse() {
+            var connection = new Connection();
+            var restResponseContent = new UsergridError {Description = "Exception message", Error = "error code"};
+            IRestResponse<LoginResponse> restResponseWithBadRequest = Helpers.SetUpRestResponseWithContent<LoginResponse>(HttpStatusCode.BadRequest, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponseWithBadRequest);
+
+            try
+            {
+                _connectionManager.CreateConnection(connection);
+                new AssertionException("UserGridException was expected to be thrown here");
+            }
+            catch (UsergridException e)
+            {
+                Assert.AreEqual("error code", e.ErrorCode);
+                Assert.AreEqual("Exception message", e.Message);
+            }
+        }
+
+        [Test]
+        public void GetConnectionsReturnsConnectionsAsList()
+        {
+            var connection = new Connection
+            {
+                ConnectorCollectionName = "users",
+                ConnectorIdentifier = "userName",
+                ConnectionName = "has"
+            };
+
+            var expectedEntities = new List<UsergridEntity>();
+            var responseData = new UsergridGetResponse<UsergridEntity>() {Entities = expectedEntities};
+            IRestResponse restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<UsergridEntity>>(HttpStatusCode.OK, responseData);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var returnedEntities = _connectionManager.GetConnections(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest("/users/userName/has",Method.GET);
+            Assert.AreEqual(expectedEntities, returnedEntities);
+        }
+
+        [Test]
+        public void GetConnectionsReturnsNullWhenConnectionIsNotFound()
+        {
+            var connection = new Connection
+            {
+                ConnectorCollectionName = "users",
+                ConnectorIdentifier = "userName",
+                ConnectionName = "has"
+            };
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.NotFound);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var returnedEntities = _connectionManager.GetConnections(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest("/users/userName/has",Method.GET);
+
+            Assert.IsNull(returnedEntities);
+        }
+
+        [Test]
+        public void GetConnectionsOfSpecificTypeReturnsConnectionsAsListOfConnecteeType()
+        {
+            var connection = new Connection
+            {
+                ConnectorCollectionName = "users",
+                ConnectorIdentifier = "userName",
+                ConnecteeCollectionName = "devices",
+                ConnectionName = "has"
+            };
+            var expectedEntities = new List<UsergridDevice>();
+            var responseData = new UsergridGetResponse<UsergridDevice>() { Entities = expectedEntities };
+            IRestResponse restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<UsergridDevice>>(HttpStatusCode.OK, responseData);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var returnedEntities = _connectionManager.GetConnections<UsergridDevice>(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest("/users/userName/has/devices", Method.GET);
+            Assert.AreEqual(expectedEntities, returnedEntities);
+        }
+
+        [Test]
+        public void GetConnectionsOfSpecificTypeReturnsNullWhenConnectionIsNotFound()
+        {
+            var connection = new Connection
+            {
+                ConnectorCollectionName = "users",
+                ConnectorIdentifier = "userName",
+                ConnecteeCollectionName = "devices",
+                ConnectionName = "has"
+            };
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.NotFound);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var returnedEntities = _connectionManager.GetConnections<UsergridDevice>(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest("/users/userName/has/devices",Method.GET);
+
+            Assert.IsNull(returnedEntities);
+        }
+
+
+        [Test]
+        public void DeleteConnectionShouldDeleteToCorrectEndpoint()
+        {
+            var connection = new Connection
+            {
+                ConnectorCollectionName = "users",
+                ConnectorIdentifier = "userName",
+                ConnecteeCollectionName = "devices",
+                ConnecteeIdentifier = "deviceName",
+                ConnectionName = "has"
+            };
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            _connectionManager.DeleteConnection(connection);
+
+            _request
+                .Received(1)
+                .ExecuteJsonRequest(
+                    "/users/userName/has/devices/deviceName",
+                    Method.DELETE);
+        }
+
+        [Test]
+        public void DeleteConnectionShouldThrowUsergridExceptionWhenBadResponse()
+        {
+            var connection = new Connection();
+            var restResponseContent = new UsergridError { Description = "Exception message", Error = "error code" };
+            IRestResponse<LoginResponse> restResponseWithBadRequest = Helpers.SetUpRestResponseWithContent<LoginResponse>(HttpStatusCode.BadRequest, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponseWithBadRequest);
+
+            try
+            {
+                _connectionManager.DeleteConnection(connection);
+                new AssertionException("UserGridException was expected to be thrown here");
+            }
+            catch (UsergridException e)
+            {
+                Assert.AreEqual("error code", e.ErrorCode);
+                Assert.AreEqual("Exception message", e.Message);
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/EntityManagerTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/EntityManagerTests.cs b/Usergrid.Sdk.Tests/EntityManagerTests.cs
new file mode 100644
index 0000000..4d3456b
--- /dev/null
+++ b/Usergrid.Sdk.Tests/EntityManagerTests.cs
@@ -0,0 +1,440 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using NSubstitute;
+using NUnit.Framework;
+using RestSharp;
+using Usergrid.Sdk.Manager;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+
+namespace Usergrid.Sdk.Tests
+{
+    [TestFixture]
+    public class EntityManagerTests
+    {
+
+        [SetUp]
+        public void Setup()
+        {
+            _request = Substitute.For<IUsergridRequest>();
+            _entityManager = new EntityManager(_request);
+        }
+
+        private IUsergridRequest _request;
+        private EntityManager _entityManager;
+
+        [Test]
+        public void CreateEntityShouldPostToCorrectEndPoint()
+        {
+            const string collectionName = "collection";
+            var entityToPost = new Friend {Name = "name1", Age = 1};
+            var restResponseContent = new UsergridGetResponse<Friend> {Entities = new List<Friend> {entityToPost}, Cursor = "cursor"};
+            IRestResponse<UsergridGetResponse<Friend>> restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            Friend returnedEntity = _entityManager.CreateEntity(collectionName, entityToPost);
+
+            _request.Received(1).ExecuteJsonRequest(
+                Arg.Is(string.Format("/{0}", collectionName)),
+                Arg.Is(Method.POST),
+                Arg.Is(entityToPost));
+
+            Assert.AreEqual(entityToPost.Age, returnedEntity.Age);
+            Assert.AreEqual(entityToPost.Name, returnedEntity.Name);
+        }
+
+        [Test]
+        public void CreateEntityShouldTranslateToUserGridErrorAndThrowWhenServiceReturnsBadRequest()
+        {
+            var restResponseContent = new UsergridError
+                                          {
+                                              Description = "Subject does not have permission",
+                                              Error = "unauthorized"
+                                          };
+            const string collectionName = "collection";
+            IRestResponse<UsergridError> restResponse = Helpers.SetUpRestResponseWithContent<UsergridError>(HttpStatusCode.BadRequest, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            try
+            {
+                _entityManager.CreateEntity(collectionName, new object());
+                new AssertionException("UserGridException was expected to be thrown here");
+            }
+            catch (UsergridException e)
+            {
+                Assert.AreEqual("unauthorized", e.ErrorCode);
+                Assert.AreEqual("Subject does not have permission", e.Message);
+            }
+        }
+
+
+        [Test]
+        public void DeleteEntityShouldSendDeleteToCorrectEndPoint()
+        {
+            const string collection = "collection";
+            const string identifier = "identifier";
+
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            _entityManager.DeleteEntity(collection, identifier);
+
+            _request.Received(1).ExecuteJsonRequest(
+                Arg.Is(string.Format("/{0}/{1}", collection, identifier)),
+                Arg.Is(Method.DELETE),
+                Arg.Any<object>());
+        }
+
+        [Test]
+        public void DeleteEntityShouldTranslateToUserGridErrorAndThrowWhenServiceReturnsNotFound()
+        {
+            var restResponseContent = new UsergridError
+                                          {
+                                              Description = "Service resource not found",
+                                              Error = "service_resource_not_found"
+                                          };
+            const string collection = "collection";
+            const string identifier = "identifier";
+
+            IRestResponse<UsergridError> restResponse = Helpers.SetUpRestResponseWithContent<UsergridError>(HttpStatusCode.NotFound, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            try
+            {
+                _entityManager.DeleteEntity(collection, identifier);
+                throw new AssertionException("UserGridException was expected to be thrown here");
+            }
+            catch (UsergridException e)
+            {
+                Assert.AreEqual("service_resource_not_found", e.ErrorCode);
+                Assert.AreEqual("Service resource not found", e.Message);
+            }
+        }
+
+        [Test]
+        public void GetEntityShouldGetToCorrectEndPoint()
+        {
+            var restResponseContent = new UsergridGetResponse<Friend> {Entities = new List<Friend>(), Cursor = ""};
+            IRestResponse<UsergridGetResponse<Friend>> restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            const string collectionName = "collection";
+            const string identifer = "identifier";
+
+            _entityManager.GetEntity<Friend>(collectionName, identifer);
+
+            _request.Received(1).ExecuteJsonRequest(
+                Arg.Is(string.Format("/{0}/{1}", collectionName, identifer)),
+                Arg.Is(Method.GET),
+                Arg.Any<object>());
+        }
+
+        [Test]
+        public void GetEntityShouldReturnEntityCorrectly()
+        {
+            var friend = new Friend {Name = "name", Age = 1};
+
+            const string restResponseContent = "{\"entities\": [" +
+                                               "{" +
+                                               "\"uuid\": \"bcb343ba-d6d1-11e2-a295-7b4b45081d3b\"," +
+                                               "\"type\": \"friend\"," +
+                                               "\"name\": \"name\"," +
+                                               "\"age\": 1," +
+                                               "\"created\": 1371420707691," +
+                                               "\"modified\": 1371420707691," +
+                                               "\"metadata\": {" +
+                                               "  \"path\": \"/friends/bcb343ba-d6d1-11e2-a295-7b4b45081d3b\"" +
+                                               "}," +
+                                               "}" +
+                                               "]}";
+            IRestResponse<UsergridGetResponse<Friend>> restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            const string collectionName = "collection";
+            const string identifier = "identifier";
+
+            Friend returnedFriend = _entityManager.GetEntity<Friend>(collectionName, identifier);
+
+            Assert.IsNotNull(returnedFriend);
+            Assert.AreEqual(friend.Name, returnedFriend.Name);
+            Assert.AreEqual(friend.Age, returnedFriend.Age);
+        }
+
+
+        [Test]
+        public void GetEntityShouldReturnFirstEntityInListCorrectly()
+        {
+            var friend1 = new Friend {Name = "name1", Age = 1};
+            var friend2 = new Friend {Name = "name2", Age = 2};
+
+            var entities = new List<Friend> {friend1, friend2};
+            var restResponseContent = new UsergridGetResponse<Friend> {Entities = entities, Cursor = "cursor"};
+            IRestResponse<UsergridGetResponse<Friend>> restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            const string collectionName = "collection";
+            const string identifier = "identifier";
+
+            Friend returnedFriend = _entityManager.GetEntity<Friend>(collectionName, identifier);
+
+            Assert.IsNotNull(returnedFriend);
+            Assert.AreEqual(friend1.Name, returnedFriend.Name);
+            Assert.AreEqual(friend1.Age, returnedFriend.Age);
+        }
+
+
+        [Test]
+        public void UpdateEntityShouldPutToCorrectEndPoint()
+        {
+            const string collectionName = "collection";
+            const string identifier = "identifier";
+            var entityToPost = new {FirstName = "first", LastName = "last"};
+
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            _entityManager.UpdateEntity(collectionName, identifier, entityToPost);
+
+            _request.Received(1).ExecuteJsonRequest(
+                Arg.Is(string.Format("/{0}/{1}", collectionName, identifier)),
+                Arg.Is(Method.PUT),
+                Arg.Is(entityToPost));
+        }
+
+        [Test]
+        public void UpdateEntityShouldTranslateToUserGridErrorAndThrowWhenServiceReturnsNotFound()
+        {
+            var restResponseContent = new UsergridError
+                                          {
+                                              Description = "Service resource not found",
+                                              Error = "service_resource_not_found"
+                                          };
+
+            const string collectionName = "collection";
+            const string identifier = "identifier";
+            var entityToPost = new {FirstName = "first", LastName = "last"};
+
+            IRestResponse<UsergridError> restResponse = Helpers.SetUpRestResponseWithContent<UsergridError>(HttpStatusCode.NotFound, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            try
+            {
+                _entityManager.UpdateEntity(collectionName, identifier, entityToPost);
+                new AssertionException("UserGridException was expected to be thrown here");
+            }
+            catch (UsergridException e)
+            {
+                Assert.AreEqual("service_resource_not_found", e.ErrorCode);
+                Assert.AreEqual("Service resource not found", e.Message);
+            }
+        }
+
+        [Test]
+        public void GetEntitiesShouldGetToCorrectEndPointWithDefaultLimitAndQuery()
+        {
+            var restResponseContent = new UsergridGetResponse<Friend> { Entities = new List<Friend>(), Cursor = "" };
+            var restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            const string collectionName = "collection";
+
+            _entityManager.GetEntities<Friend>(collectionName);
+
+            _request.Received(1).ExecuteJsonRequest(
+                Arg.Is(string.Format("/{0}?limit=10", collectionName)),
+                Arg.Is(Method.GET),
+                Arg.Is<object>(x=> x == null));
+        }
+
+        [Test]
+        public void GetEntitiesShouldReturnListCorrectly()
+        {
+            var friend1 = new Friend { Name = "name1", Age = 1 };
+            var friend2 = new Friend { Name = "name2", Age = 2 };
+            var entities = new List<Friend> { friend1, friend2 };
+            var restResponseContent = new UsergridGetResponse<Friend> { Entities = entities, Cursor = "cursor" };
+            var restResponse = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent);
+
+            _request
+                .ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var friends = _entityManager.GetEntities<Friend>("collection");
+
+            Assert.IsNotNull(friends);
+            Assert.AreEqual(entities.Count, friends.Count);
+            Assert.AreEqual(friend1.Name, friends[0].Name);
+            Assert.AreEqual(friend1.Age, friends[0].Age);
+            Assert.AreEqual(friend2.Name, friends[1].Name);
+            Assert.AreEqual(friend2.Age, friends[1].Age);
+        }
+
+        [Test]
+        public void GetNextEntitiesShouldReturnEmptyListIfCalledBeforeGetEntities()
+        {
+            var friends = _entityManager.GetNextEntities<Friend>("collection");
+
+            CollectionAssert.IsEmpty(friends);
+        }
+
+        [Test]
+        public void GetNextEntitiesShouldGetToCorrectEndPointWithCorrectCursorState()
+        {
+            var friend1 = new Friend { Name = "name1", Age = 1 };
+            var friend2 = new Friend { Name = "name2", Age = 2 };
+            var friend3 = new Friend { Name = "name3", Age = 3 };
+            var friend4 = new Friend { Name = "name4", Age = 4 };
+            var friend5 = new Friend { Name = "name5", Age = 5 };
+            var friend6 = new Friend { Name = "name6", Age = 6 };
+            var entities1 = new List<Friend> { friend1, friend2 };
+            var entities2 = new List<Friend> { friend3, friend4 };
+            var entities3 = new List<Friend> { friend5, friend6 };
+            var restResponseContent1 = new UsergridGetResponse<Friend> { Entities = entities1, Cursor = "cursor1" };
+            var restResponse1 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent1);
+            var restResponseContent2 = new UsergridGetResponse<Friend> { Entities = entities2, Cursor = "cursor2" };
+            var restResponse2 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent2);
+            var restResponseContent3 = new UsergridGetResponse<Friend> { Entities = entities3 };
+            var restResponse3 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent3);
+
+            _request
+                .ExecuteJsonRequest("/collection?limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse1);
+            _request
+                .ExecuteJsonRequest("/collection?cursor=cursor1&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse2);
+            _request
+                .ExecuteJsonRequest("/collection?cursor=cursor2&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse3);
+
+            UsergridCollection<Friend> list1 = _entityManager.GetEntities<Friend>("collection");
+            UsergridCollection<Friend> list2 = _entityManager.GetNextEntities<Friend>("collection");
+            UsergridCollection<Friend> list3 = _entityManager.GetNextEntities<Friend>("collection");
+
+            Assert.AreEqual(entities1[0].Name,list1[0].Name);
+            Assert.AreEqual(entities1[1].Age,list1[1].Age);
+            Assert.IsTrue(list1.HasNext);
+            Assert.IsFalse(list1.HasPrevious);
+            Assert.AreEqual(entities2[0].Name,list2[0].Name);
+            Assert.AreEqual(entities2[1].Age,list2[1].Age);
+            Assert.IsTrue(list2.HasNext);
+            Assert.IsTrue(list2.HasPrevious);
+            Assert.AreEqual(entities3[0].Name,list3[0].Name);
+            Assert.AreEqual(entities3[1].Age,list3[1].Age);
+            Assert.IsFalse(list3.HasNext);
+            Assert.IsTrue(list3.HasPrevious);
+        }
+
+        [Test]
+        public void GetPreviousEntitiesShouldGetToCorrectEndPointWithCorrectCursorState()
+        {
+            var friend1 = new Friend { Name = "name1", Age = 1 };
+            var friend2 = new Friend { Name = "name2", Age = 2 };
+            var friend3 = new Friend { Name = "name3", Age = 3 };
+            var friend4 = new Friend { Name = "name4", Age = 4 };
+            var friend5 = new Friend { Name = "name5", Age = 5 };
+            var friend6 = new Friend { Name = "name6", Age = 6 };
+            var entities1 = new List<Friend> { friend1, friend2 };
+            var entities2 = new List<Friend> { friend3, friend4 };
+            var entities3 = new List<Friend> { friend5, friend6 };
+            var restResponseContent1 = new UsergridGetResponse<Friend> { Entities = entities1, Cursor = "cursor1" };
+            var restResponse1 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent1);
+            var restResponseContent2 = new UsergridGetResponse<Friend> { Entities = entities2, Cursor = "cursor2" };
+            var restResponse2 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent2);
+            var restResponseContent3 = new UsergridGetResponse<Friend> { Entities = entities3 };
+            var restResponse3 = Helpers.SetUpRestResponseWithContent<UsergridGetResponse<Friend>>(HttpStatusCode.OK, restResponseContent3);
+
+            _request
+               .ExecuteJsonRequest("/collection?limit=10", Method.GET, Arg.Is<object>(x => x == null))
+               .Returns(restResponse1);
+            _request
+                .ExecuteJsonRequest("/collection?cursor=cursor1&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse2);
+            _request
+                .ExecuteJsonRequest("/collection?cursor=cursor2&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse3);
+            _request
+                .ExecuteJsonRequest("/collection?cursor=cursor1&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse2);
+            _request
+                .ExecuteJsonRequest("/collection?&limit=10", Method.GET, Arg.Is<object>(x => x == null))
+                .Returns(restResponse1);
+
+            UsergridCollection<Friend> list1 = _entityManager.GetEntities<Friend>("collection");
+            UsergridCollection<Friend> list2 = _entityManager.GetNextEntities<Friend>("collection");
+            UsergridCollection<Friend> list3 = _entityManager.GetNextEntities<Friend>("collection");
+            UsergridCollection<Friend> list4 = _entityManager.GetPreviousEntities<Friend>("collection");
+            UsergridCollection<Friend> list5 = _entityManager.GetPreviousEntities<Friend>("collection");
+
+            Assert.AreEqual(entities1[0].Name,list1[0].Name);
+            Assert.AreEqual(entities1[1].Age,list1[1].Age);
+            Assert.IsTrue(list1.HasNext);
+            Assert.IsFalse(list1.HasPrevious);
+
+            Assert.AreEqual(entities2[0].Name,list2[0].Name);
+            Assert.AreEqual(entities2[1].Age,list2[1].Age);
+            Assert.IsTrue(list2.HasNext);
+            Assert.IsTrue(list2.HasPrevious);
+            
+            Assert.AreEqual(entities3[0].Name,list3[0].Name);
+            Assert.AreEqual(entities3[1].Age,list3[1].Age);
+            Assert.IsFalse(list3.HasNext);
+            Assert.IsTrue(list3.HasPrevious);
+
+            Assert.AreEqual(entities2[0].Name, list4[0].Name);
+            Assert.AreEqual(entities2[1].Age, list4[1].Age);
+            Assert.IsTrue(list4.HasNext);
+            Assert.IsTrue(list4.HasPrevious);
+
+            Assert.AreEqual(entities1[0].Name, list5[0].Name);
+            Assert.AreEqual(entities1[1].Age, list5[1].Age);
+            Assert.IsTrue(list5.HasNext);
+            Assert.IsFalse(list5.HasPrevious);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Friend.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Friend.cs b/Usergrid.Sdk.Tests/Friend.cs
new file mode 100644
index 0000000..ea6cc32
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Friend.cs
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System.Collections.Generic;
+using System.Net;
+using NSubstitute;
+using NUnit.Framework;
+using RestSharp;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+
+namespace Usergrid.Sdk.Tests
+{
+
+    public class Friend
+    {
+        public string Name { get; set; }
+        public int Age { get; set; }
+    }
+
+   
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Helpers.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Helpers.cs b/Usergrid.Sdk.Tests/Helpers.cs
new file mode 100644
index 0000000..6188d16
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Helpers.cs
@@ -0,0 +1,94 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System.Net;
+using System.Reflection;
+using NSubstitute;
+using Newtonsoft.Json;
+using RestSharp;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+
+namespace Usergrid.Sdk.Tests
+{
+	internal static class Helpers
+    {
+		internal static string Serialize(this object obj)
+        {
+            return JsonConvert.SerializeObject(obj);
+        }
+
+		internal static IRestResponse<T> SetUpRestResponseWithContent<T>(HttpStatusCode httpStatusCode, object responseContent)
+		{
+		    return SetUpRestResponseWithContent<T>(httpStatusCode, responseContent.Serialize());
+		}
+		
+        internal static IRestResponse<T> SetUpRestResponseWithContent<T>(HttpStatusCode httpStatusCode, string responseContent)
+        {
+            var restResponse = Substitute.For<IRestResponse<T>>();
+            restResponse.StatusCode.Returns(httpStatusCode);
+            restResponse.Content.Returns(responseContent);
+            return restResponse;
+        }
+
+        internal static IRestResponse SetUpRestResponse(HttpStatusCode httpStatusCode)
+        {
+            var restResponse = Substitute.For<IRestResponse>();
+            restResponse.StatusCode.Returns(httpStatusCode);
+            return restResponse;
+        }
+
+		internal static IRestResponse<T> SetUpRestResponseWithData<T>(HttpStatusCode httpStatusCode, T responseData)
+        {
+            var restResponse = Substitute.For<IRestResponse<T>>();
+            restResponse.StatusCode.Returns(httpStatusCode);
+            restResponse.Data.Returns(responseData);
+            return restResponse;
+        }
+
+        internal static IUsergridRequest SetUpUsergridRequestWithRestResponse<T>(IRestResponse<T> restResponse) where T : new()
+        {
+            var request = Substitute.For<IUsergridRequest>();
+            request
+                .ExecuteJsonRequest<T>(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            return request;
+        }
+
+		internal static IUsergridRequest InitializeUserGridRequestWithAccessToken(string accessToken)
+        {
+            IRestResponse<LoginResponse> loginResponse = SetUpRestResponseWithData(HttpStatusCode.OK, new LoginResponse {AccessToken = accessToken});
+
+            var request = Substitute.For<IUsergridRequest>();
+            request
+                .ExecuteJsonRequest<LoginResponse>(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(loginResponse);
+
+            return request;
+        }
+
+        public static object GetReflectedProperty(this object obj, string propertyName)
+        {
+            PropertyInfo property = obj.GetType().GetProperty(propertyName);
+
+            if (property == null)
+                return null;
+
+            return property.GetValue(obj, null);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Model/NotificationRecipientsTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Model/NotificationRecipientsTests.cs b/Usergrid.Sdk.Tests/Model/NotificationRecipientsTests.cs
new file mode 100644
index 0000000..032e733
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Model/NotificationRecipientsTests.cs
@@ -0,0 +1,147 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System;
+using NSubstitute.Core;
+using NUnit.Framework;
+using Usergrid.Sdk.Model;
+
+namespace Usergrid.Sdk.Tests.Model
+{
+    [TestFixture]
+    public class NotificationRecipientsTests
+    {
+        [Test]
+        public void NotificationRecipientsBuildsQuery1()
+        {
+            var query = new NotificationRecipients()
+                .AddDeviceWithName("d")
+                .AddGroupWithPath("p")
+                .AddUserWithName("u")
+                .BuildQuery();
+
+            Assert.AreEqual("/groups/p/users/u/devices/d/notifications", query);
+        }
+
+        [Test]
+        public void NotificationRecipientsBuildsQuery2()
+        {
+            var query = new NotificationRecipients()
+                .AddDeviceWithName("d")
+                .AddGroupWithPath("p")
+                .AddUserWithUuid("u")
+                .BuildQuery();
+
+            Assert.AreEqual("/groups/p/users/u/devices/d/notifications", query);
+        }
+
+        [Test]
+        public void NotificationRecipientsBuildsQuery3()
+        {
+            var query = new NotificationRecipients()
+                .AddDeviceWithQuery("d")
+                .AddGroupWithQuery("p")
+                .AddUserWithQuery("u")
+                .BuildQuery();
+
+            Assert.AreEqual("/groups;ql=p/users;ql=u/devices;ql=d/notifications", query);
+        }
+        [Test]
+        public void NotificationRecipientsBuildsQuery4()
+        {
+            var query = new NotificationRecipients()
+                .AddDeviceWithQuery(string.Empty)
+                .AddGroupWithQuery(string.Empty)
+                .AddUserWithQuery(string.Empty)
+                .BuildQuery();
+
+            Assert.AreEqual("/groups;ql=/users;ql=/devices;ql=/notifications", query);
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "User name and uuid can not be added at the same time.")]
+        public void UserNameAndUuidCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddUserWithName("u")
+                .AddUserWithUuid("i");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "User name and uuid can not be added at the same time.")]
+        public void UserUuidAndNameCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddUserWithUuid("i")
+                .AddUserWithName("u");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "User query can not be added together with user name or uuid.")]
+        public void UserUuidAndQueryCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddUserWithUuid("i")
+                .AddUserWithQuery("u");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "User query can not be added together with user name or uuid.")]
+        public void UserNameAndQueryCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddUserWithName("i")
+                .AddUserWithQuery("u");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Group path and query can not be added at the same time.")]
+        public void GroupPathAndQueryCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddGroupWithPath("u")
+                .AddGroupWithQuery("i");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Group path and query can not be added at the same time.")]
+        public void GroupQueryAndPathCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddGroupWithQuery("i")
+                .AddGroupWithPath("u");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Device name and query can not be added at the same time.")]
+        public void DeviceQueryAndNameCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddDeviceWithQuery("i")
+                .AddDeviceWithName("u");
+        }
+
+        [Test]
+        [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Device name and query can not be added at the same time.")]
+        public void DeviceNameAndQueryCannotBeAddedAtTheSameTime()
+        {
+            new NotificationRecipients()
+                .AddDeviceWithName("i")
+                .AddDeviceWithQuery("u");
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Model/NotificationTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Model/NotificationTests.cs b/Usergrid.Sdk.Tests/Model/NotificationTests.cs
new file mode 100644
index 0000000..2bea74c
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Model/NotificationTests.cs
@@ -0,0 +1,55 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using NUnit.Framework;
+using Usergrid.Sdk.Model;
+
+namespace Usergrid.Sdk.Tests.Model
+{
+    [TestFixture]
+    public class NotificationTests
+    {
+        [Test]
+        public void AndroidNotificationShouldReturnCorrectPayload()
+        {
+            var notification = new AndroidNotification("notifierName", "notification message");
+            var payload = notification.GetPayload();
+
+            Assert.AreEqual("notification message", payload.GetReflectedProperty("data"));
+        }
+
+        [Test]
+        public void GoogleNotificationShouldReturnCorrectPayloadWithSound()
+        {
+            var notification = new AppleNotification("notifierName", "notification message", "chime");
+            var payload = notification.GetPayload();
+
+            var aps = payload.GetReflectedProperty("aps");
+            Assert.IsNotNull(aps);
+            Assert.AreEqual("notification message", aps.GetReflectedProperty("alert"));
+            Assert.AreEqual("chime", aps.GetReflectedProperty("sound"));
+        }
+
+        [Test]
+        public void GoogleNotificationShouldReturnCorrectPayloadWithoutSound()
+        {
+            var notification = new AppleNotification("notifierName", "notification message");
+            var payload = notification.GetPayload();
+
+            Assert.AreEqual("notification message", payload);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/NotificationsManagerTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/NotificationsManagerTests.cs b/Usergrid.Sdk.Tests/NotificationsManagerTests.cs
new file mode 100644
index 0000000..ae5135a
--- /dev/null
+++ b/Usergrid.Sdk.Tests/NotificationsManagerTests.cs
@@ -0,0 +1,118 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using NSubstitute;
+using NUnit.Framework;
+using RestSharp;
+using Usergrid.Sdk.Manager;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+
+namespace Usergrid.Sdk.Tests
+{
+    [TestFixture]
+    public class NotificationsManagerTests
+    {
+        private IUsergridRequest _request;
+        private NotificationsManager _notificationsManager;
+
+        [SetUp]
+        public void Setup()
+        {
+            _request = Substitute.For<IUsergridRequest>();
+            _notificationsManager = new NotificationsManager(_request);
+        }
+
+
+        [Test]
+        public void CreateNotifierForAppleExecutesMultipartFormDataRequestWithCorrectParameters()
+        {
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+            _request.ExecuteMultipartFormDataRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<IDictionary<string, object>>(), Arg.Any<IDictionary<string, string>>())
+                .Returns(restResponse);
+
+            _notificationsManager.CreateNotifierForApple("notifierName", "development", @"C:\filePath");
+
+            _request.Received(1).ExecuteMultipartFormDataRequest(
+                "/notifiers",
+                Method.POST,
+                Arg.Is<IDictionary<string, object>>(d => (string) d["name"] == "notifierName" && (string) d["provider"] == "apple" && (string) d["environment"] == "development"),
+                Arg.Is<IDictionary<string, string>>(d => d["p12Certificate"] == @"C:\filePath"));
+        }
+
+        [Test]
+        public void CreateNotifierForAndroidExecutesMultipartFormDataRequestWithCorrectParameters()
+        {
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+            _request.ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            _notificationsManager.CreateNotifierForAndroid("notifierName", "apiKey");
+
+            _request.Received(1).ExecuteJsonRequest(
+                "/notifiers",
+                Method.POST,
+                Arg.Is<AndroidNotifierPayload>(p => p.ApiKey == "apiKey" && p.Name == "notifierName" && p.Provider == "google"));
+        }
+
+        [Test]
+        public void PublishNotificationPostsByBuildingQueryAndPayload()
+        {
+            IRestResponse restResponse = Helpers.SetUpRestResponse(HttpStatusCode.OK);
+            _request.ExecuteJsonRequest(Arg.Any<string>(), Arg.Any<Method>(), Arg.Any<object>())
+                .Returns(restResponse);
+
+            var recipients = Substitute.For<INotificationRecipients>();
+            recipients.BuildQuery().Returns("query");
+
+            var appleNotification = new AppleNotification("appleNotifierName", "appleTestMessge", "chime");
+            var googleNotification = new AndroidNotification("googleNotifierName", "androidTestMessage");
+
+            var deliverAt = DateTime.Now.AddDays(1);
+            var expireAt = DateTime.Now.AddDays(2);
+
+            var schedulerSettings = new NotificationSchedulerSettings {DeliverAt = deliverAt, ExpireAt = expireAt};
+
+            //call PublishNotification
+            _notificationsManager.PublishNotification(new Notification[] {appleNotification, googleNotification}, recipients, schedulerSettings);
+
+            //assert
+            recipients.Received(1).BuildQuery();
+
+            Func<NotificationPayload, bool> validatePayload = p =>
+                                                                  {
+                                                                      bool isValid = true;
+                                                                      isValid &= p.DeliverAt == deliverAt.ToUnixTime();
+                                                                      isValid &= p.ExpireAt == expireAt.ToUnixTime();
+
+                                                                      var applePayload = p.Payloads["appleNotifierName"].GetReflectedProperty("aps");
+                                                                      isValid &= (string) applePayload.GetReflectedProperty("alert") == "appleTestMessge";
+                                                                      isValid &= (string) applePayload.GetReflectedProperty("sound") == "chime";
+
+                                                                      var googlePayload = p.Payloads["googleNotifierName"].GetReflectedProperty("data");
+                                                                      isValid &= (string) googlePayload == "androidTestMessage";
+
+                                                                      return isValid;
+                                                                  };
+            _request.Received(1).ExecuteJsonRequest("query", Method.POST,
+                                                    Arg.Is<NotificationPayload>(
+                                                        p => validatePayload(p)));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Properties/AssemblyInfo.cs b/Usergrid.Sdk.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..eae3356
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,57 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Usergrid.Sdk.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Usergrid.Sdk.Tests")]
+[assembly: AssemblyCopyright("Copyright � Microsoft 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("7f12bc68-97ae-41c8-bc55-87ef2ecfb2f7")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("0.1.0.0")]
+[assembly: AssemblyFileVersion("0.1.0.0")]
+
+[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/Usergrid.Sdk.Tests.csproj
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/Usergrid.Sdk.Tests.csproj b/Usergrid.Sdk.Tests/Usergrid.Sdk.Tests.csproj
new file mode 100644
index 0000000..a3aff04
--- /dev/null
+++ b/Usergrid.Sdk.Tests/Usergrid.Sdk.Tests.csproj
@@ -0,0 +1,110 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{9C25CFBA-1F57-4DF3-B0A1-52D1F90F24E6}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Usergrid.Sdk.Tests</RootNamespace>
+    <AssemblyName>Usergrid.Sdk.Tests</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="nunit.framework">
+      <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="NSubstitute">
+      <HintPath>..\packages\NSubstitute.1.6.0.0\lib\NET40\NSubstitute.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="RestSharp">
+      <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ClientTests\ConnectionTests.cs" />
+    <Compile Include="ClientTests\ActivityTests.cs" />
+    <Compile Include="ClientTests\FeedTests.cs" />
+    <Compile Include="ClientTests\NotificationTests.cs" />
+    <Compile Include="ClientTests\DeviceTests.cs" />
+    <Compile Include="ClientTests\GroupTests.cs" />
+    <Compile Include="ClientTests\UserTests.cs" />
+    <Compile Include="ClientTests\EntityTests.cs" />
+    <Compile Include="ClientTests\LoginTests.cs" />
+    <Compile Include="ConnectionManagerTests.cs" />
+    <Compile Include="UsergridRequestTests.cs" />
+    <Compile Include="Model\NotificationRecipientsTests.cs" />
+    <Compile Include="Model\NotificationTests.cs" />
+    <Compile Include="NotificationsManagerTests.cs" />
+    <Compile Include="EntityManagerTests.cs" />
+    <Compile Include="Helpers.cs" />
+    <Compile Include="AuthenticationManagerTests.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Friend.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Usergrid.Sdk\Usergrid.Sdk.csproj">
+      <Project>{437D108F-528C-4B2A-B399-06CF02DEB08B}</Project>
+      <Name>Usergrid.Sdk</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/UsergridRequestTests.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/UsergridRequestTests.cs b/Usergrid.Sdk.Tests/UsergridRequestTests.cs
new file mode 100644
index 0000000..b5fb7f1
--- /dev/null
+++ b/Usergrid.Sdk.Tests/UsergridRequestTests.cs
@@ -0,0 +1,140 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System;
+using System.Collections.Generic;
+using NSubstitute;
+using NUnit.Framework;
+using RestSharp;
+using RestSharp.Serializers;
+
+namespace Usergrid.Sdk.Tests
+{
+    [TestFixture]
+    public class UsergridRequestTests
+    {
+        [Test]
+        public void ExecuteJsonRequestAddsAuthorizationHeader()
+        {
+            var restClient = Substitute.For<IRestClient>();
+            var usergridRequest = new UsergridRequest("http://usergrid.com", "org", "app", restClient);
+            usergridRequest.AccessToken = "accessToken";
+
+            usergridRequest.ExecuteJsonRequest("/resource", Method.POST);
+
+
+            Func<RestRequest, bool> ValidateRequest = r => r.Parameters[0].Name == "Authorization" &&
+                                                           (string)r.Parameters[0].Value == "Bearer accessToken" &&
+                                                           r.Parameters[0].Type == ParameterType.HttpHeader &&
+                                                           r.Method == Method.POST;
+            restClient.Received(1).Execute(Arg.Is<RestRequest>(r=>ValidateRequest(r)));
+        }
+
+        [Test]
+        public void GenericExecuteJsonRequestAddsAuthorizationHeader()
+        {
+            var restClient = Substitute.For<IRestClient>();
+            var usergridRequest = new UsergridRequest("http://usergrid.com", "org", "app", restClient);
+            usergridRequest.AccessToken = "accessToken";
+
+            usergridRequest.ExecuteJsonRequest<object>("/resource", Method.POST);
+
+
+            Func<RestRequest, bool> ValidateRequest = r => r.Parameters[0].Name == "Authorization" &&
+                                                           (string)r.Parameters[0].Value == "Bearer accessToken" &&
+                                                           r.Parameters[0].Type == ParameterType.HttpHeader &&
+                                                           r.Method == Method.POST;
+            restClient.Received(1).Execute<object>(Arg.Is<RestRequest>(r=>ValidateRequest(r)));
+        }
+
+        [Test]
+        public void ExecuteJsonRequestAddsBodyAsJsonAndSetsSerializer()
+        {
+            var restClient = Substitute.For<IRestClient>();
+            var body = new {data="test"};
+            var usergridRequest = new UsergridRequest("http://usergrid.com", "org", "app", restClient);
+
+            usergridRequest.ExecuteJsonRequest("/resource", Method.POST, body);
+
+
+            Func<RestRequest, bool> ValidateRequest = r => 
+                (string)r.Parameters[0].Value == "{\"data\":\"test\"}"&& 
+                r.RequestFormat == DataFormat.Json &&
+                r.JsonSerializer is RestSharpJsonSerializer;
+            restClient.Received(1).Execute(Arg.Is<RestRequest>(r => ValidateRequest(r)));
+        }
+
+        [Test]
+        public void GenericExecuteJsonRequestAddsBodyAsJsonAndSetsSerializer()
+        {
+            var restClient = Substitute.For<IRestClient>();
+            var body = new {data="test"};
+            var usergridRequest = new UsergridRequest("http://usergrid.com", "org", "app", restClient);
+
+            usergridRequest.ExecuteJsonRequest<object>("/resource", Method.POST, body);
+
+
+            Func<RestRequest, bool> ValidateRequest = r => 
+                (string)r.Parameters[0].Value == "{\"data\":\"test\"}"&& 
+                r.RequestFormat == DataFormat.Json &&
+                r.JsonSerializer is RestSharpJsonSerializer;
+            restClient.Received(1).Execute<object>(Arg.Is<RestRequest>(r => ValidateRequest(r)));
+        }
+
+        [Test]
+        public void ExecuteMultipartFormDataRequestAddsFormsParametersAndFileParameters()
+        {
+            var restClient = Substitute.For<IRestClient>();
+            var usergridRequest = new UsergridRequest("http://usergrid.com", "org", "app", restClient);
+
+            IDictionary<string, object> formParameters = new Dictionary<string, object>()
+                                                             {
+                                                                 {"param1", "value1"},
+                                                                 {"param2", "value2"}
+                                                             };
+
+            IDictionary<string, string> fileParameters = new Dictionary<string, string>()
+                                                             {
+                                                                 {"fileParam1", "filePath1"}
+                                                             };
+
+            usergridRequest.ExecuteMultipartFormDataRequest("/resource", Method.POST, formParameters, fileParameters);
+
+
+            Func<RestRequest, bool> ValidateRequest = r =>
+                                                          {
+                                                              bool isValid = true;
+                                                              isValid &= r.Parameters[0].Name == "param1";
+                                                              isValid &= (string)r.Parameters[0].Value == "value1";
+                                                              isValid &= r.Parameters[0].Type == ParameterType.GetOrPost;
+
+                                                              isValid &= r.Parameters[1].Name == "param2";
+                                                              isValid &= (string)r.Parameters[1].Value == "value2";
+                                                              isValid &= r.Parameters[1].Type == ParameterType.GetOrPost;
+
+                                                              isValid &= r.Files[0].Name == "fileParam1";
+                                                              isValid &= r.Files[0].FileName == "filePath1";
+
+                                                              return isValid;
+                                                          };
+
+
+            restClient.Received(1).Execute(Arg.Is<RestRequest>(r => ValidateRequest(r)));
+
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk.Tests/packages.config
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk.Tests/packages.config b/Usergrid.Sdk.Tests/packages.config
new file mode 100644
index 0000000..f3b5dc9
--- /dev/null
+++ b/Usergrid.Sdk.Tests/packages.config
@@ -0,0 +1,24 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<packages>
+  <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
+  <package id="NSubstitute" version="1.6.0.0" targetFramework="net40" />
+  <package id="NUnit" version="2.6.2" targetFramework="net40" />
+  <package id="RestSharp" version="104.1" targetFramework="net40" />
+</packages>

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk/Client.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk/Client.cs b/Usergrid.Sdk/Client.cs
new file mode 100644
index 0000000..9870c33
--- /dev/null
+++ b/Usergrid.Sdk/Client.cs
@@ -0,0 +1,262 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Collections.Generic;
+using System.Net;
+using Newtonsoft.Json;
+using RestSharp;
+using Usergrid.Sdk.Manager;
+using Usergrid.Sdk.Model;
+using Usergrid.Sdk.Payload;
+using AuthenticationManager = Usergrid.Sdk.Manager.AuthenticationManager;
+
+namespace Usergrid.Sdk {
+    public class Client : IClient {
+        private const string UserGridEndPoint = "http://api.usergrid.com";
+        private readonly IUsergridRequest _request;
+
+        private IAuthenticationManager _authenticationManager;
+        private IConnectionManager _connectionManager;
+        private IEntityManager _entityManager;
+        private INotificationsManager _notificationsManager;
+
+        public Client(string organization, string application)
+            : this(organization, application, UserGridEndPoint, new UsergridRequest(UserGridEndPoint, organization, application)) {}
+
+        public Client(string organization, string application, string uri = UserGridEndPoint)
+            : this(organization, application, uri, new UsergridRequest(uri, organization, application)) {}
+
+        internal Client(string organization, string application, string uri = UserGridEndPoint, IUsergridRequest request = null) {
+            _request = request ?? new UsergridRequest(uri, organization, application);
+        }
+
+        internal IAuthenticationManager AuthenticationManager {
+            get { return _authenticationManager ?? (_authenticationManager = new AuthenticationManager(_request)); }
+            set { _authenticationManager = value; }
+        }
+
+        internal IEntityManager EntityManager {
+            get { return _entityManager ?? (_entityManager = new EntityManager(_request)); }
+            set { _entityManager = value; }
+        }
+
+        internal IConnectionManager ConnectionManager {
+            get { return _connectionManager ?? (_connectionManager = new ConnectionManager(_request)); }
+            set { _connectionManager = value; }
+        }
+
+        internal INotificationsManager NotificationsManager {
+            get { return _notificationsManager ?? (_notificationsManager = new NotificationsManager(_request)); }
+            set { _notificationsManager = value; }
+        }
+
+        public void Login(string loginId, string secret, AuthType authType) {
+            AuthenticationManager.Login(loginId, secret, authType);
+        }
+
+        public T CreateEntity<T>(string collection, T entity) {
+            return EntityManager.CreateEntity(collection, entity);
+        }
+
+        public void DeleteEntity(string collection, string name) {
+            EntityManager.DeleteEntity(collection, name);
+        }
+
+        public void UpdateEntity<T>(string collection, string identifier, T entity) {
+            EntityManager.UpdateEntity(collection, identifier, entity);
+        }
+
+        public T GetEntity<T>(string collectionName, string entityIdentifier) {
+            return EntityManager.GetEntity<T>(collectionName, entityIdentifier);
+        }
+
+        public T GetUser<T>(string identifer /*username or uuid or email*/) where T : UsergridUser {
+            var user = GetEntity<T>("users", identifer);
+            if (user == null)
+                return null;
+
+            return user;
+        }
+
+        public void CreateUser<T>(T user) where T : UsergridUser {
+            CreateEntity("users", user);
+        }
+
+        public void UpdateUser<T>(T user) where T : UsergridUser {
+            UpdateEntity("users", user.UserName, user);
+        }
+
+        public void DeleteUser(string identifer /*username or uuid or email*/) {
+            DeleteEntity("users", identifer);
+        }
+
+        public void ChangePassword(string identifer /*username or uuid or email*/, string oldPassword, string newPassword) {
+            AuthenticationManager.ChangePassword(identifer, oldPassword, newPassword);
+        }
+
+        public void CreateGroup<T>(T group) where T : UsergridGroup {
+            CreateEntity("groups", group);
+        }
+
+        public void DeleteGroup(string path) {
+            DeleteEntity("groups", path);
+        }
+
+        public T GetGroup<T>(string identifer /*uuid or path*/) where T : UsergridGroup {
+            var usergridGroup = EntityManager.GetEntity<T>("groups", identifer);
+            if (usergridGroup == null)
+                return null;
+
+            return usergridGroup;
+        }
+
+        public void UpdateGroup<T>(T group) where T : UsergridGroup {
+            UpdateEntity("groups", group.Path, group);
+        }
+
+        public void AddUserToGroup(string groupIdentifier, string userName) {
+            EntityManager.CreateEntity<object>(string.Format("/groups/{0}/users/{1}", groupIdentifier, userName), null);
+        }
+
+        public void DeleteUserFromGroup(string groupIdentifier, string userIdentifier) {
+            DeleteEntity("/groups/" + groupIdentifier + "/users", userIdentifier);
+        }
+
+        public IList<T> GetAllUsersInGroup<T>(string groupName) where T : UsergridUser {
+            IRestResponse response = _request.ExecuteJsonRequest(string.Format("/groups/{0}/users", groupName), Method.GET);
+            ValidateResponse(response);
+
+            var responseObject = JsonConvert.DeserializeObject<UsergridGetResponse<T>>(response.Content);
+            return responseObject.Entities;
+        }
+
+        public UsergridCollection<T> GetEntities<T>(string collection, int limit = 10, string query = null) {
+            return EntityManager.GetEntities<T>(collection, limit, query);
+        }
+
+        public UsergridCollection<T> GetNextEntities<T>(string collection, string query = null) {
+            return EntityManager.GetNextEntities<T>(collection, query);
+        }
+
+        public UsergridCollection<T> GetPreviousEntities<T>(string collection, string query = null) {
+            return EntityManager.GetPreviousEntities<T>(collection, query);
+        }
+
+        public void CreateConnection(Connection connection) {
+            ConnectionManager.CreateConnection(connection);
+        }
+        public IList<UsergridEntity> GetConnections(Connection connection) {
+            return ConnectionManager.GetConnections(connection);
+        }
+        public IList<TConnectee> GetConnections<TConnectee>(Connection connection) {
+            return ConnectionManager.GetConnections<TConnectee>(connection);
+        }
+        public void DeleteConnection(Connection connection) {
+            ConnectionManager.DeleteConnection(connection);
+        }
+
+        public void PostActivity<T>(string userIdentifier, T activity) where T : UsergridActivity {
+            string collection = string.Format("/users/{0}/activities", userIdentifier);
+            EntityManager.CreateEntity(collection, activity);
+        }
+
+        public void PostActivityToGroup<T>(string groupIdentifier, T activity) where T : UsergridActivity {
+            string collection = string.Format("/groups/{0}/activities", groupIdentifier);
+            EntityManager.CreateEntity(collection, activity);
+        }
+
+        public void PostActivityToUsersFollowersInGroup<T>(string userIdentifier, string groupIdentifier, T activity) where T : UsergridActivity {
+            string collection = string.Format("/groups/{0}/users/{1}/activities", groupIdentifier, userIdentifier);
+            EntityManager.CreateEntity(collection, activity);
+        }
+
+        public UsergridCollection<T> GetUserActivities<T>(string userIdentifier) where T : UsergridActivity {
+            string collection = string.Format("/users/{0}/activities", userIdentifier);
+            return EntityManager.GetEntities<T>(collection);
+        }
+
+        public UsergridCollection<T> GetGroupActivities<T>(string groupIdentifier) where T : UsergridActivity {
+            string collection = string.Format("/groups/{0}/activities", groupIdentifier);
+            return EntityManager.GetEntities<T>(collection);
+        }
+
+        public T GetDevice<T>(string identifer) where T : UsergridDevice {
+            var device = GetEntity<T>("devices", identifer);
+            if (device == null)
+                return null;
+
+            return device;
+        }
+
+        public void UpdateDevice<T>(T device) where T : UsergridDevice {
+            UpdateEntity("devices", device.Name, device);
+        }
+
+        public void CreateDevice<T>(T device) where T : UsergridDevice {
+            CreateEntity("devices", device);
+        }
+
+        public void DeleteDevice(string identifer) {
+            DeleteEntity("devices", identifer);
+        }
+
+        public void CreateNotifierForApple(string notifierName, string environment, string p12CertificatePath) {
+            NotificationsManager.CreateNotifierForApple(notifierName, environment, p12CertificatePath);
+        }
+
+        public void CreateNotifierForAndroid(string notifierName, string apiKey) {
+            NotificationsManager.CreateNotifierForAndroid(notifierName, apiKey);
+        }
+
+        public T GetNotifier<T>(string identifer /*uuid or notifier name*/) where T : UsergridNotifier {
+            var usergridNotifier = EntityManager.GetEntity<T>("/notifiers", identifer);
+            if (usergridNotifier == null)
+                return null;
+
+            return usergridNotifier;
+        }
+
+        public void DeleteNotifier(string notifierName) {
+            EntityManager.DeleteEntity("/notifiers", notifierName);
+        }
+
+        public void PublishNotification(IEnumerable<Notification> notifications, INotificationRecipients recipients, NotificationSchedulerSettings schedulerSettings = null) {
+            NotificationsManager.PublishNotification(notifications, recipients, schedulerSettings);
+        }
+
+        public void CancelNotification(string notificationIdentifier) {
+            EntityManager.UpdateEntity("/notifications", notificationIdentifier, new CancelNotificationPayload {Canceled = true});
+        }
+
+        //TODO: IList?
+        public UsergridCollection<T> GetUserFeed<T>(string userIdentifier) where T : UsergridActivity {
+            string collection = string.Format("/users/{0}/feed", userIdentifier);
+            return EntityManager.GetEntities<T>(collection);
+        }
+
+        public UsergridCollection<T> GetGroupFeed<T>(string groupIdentifier) where T : UsergridActivity {
+            string collection = string.Format("/groups/{0}/feed", groupIdentifier);
+            return EntityManager.GetEntities<T>(collection);
+        }
+
+
+        private static void ValidateResponse(IRestResponse response) {
+            if (response.StatusCode != HttpStatusCode.OK) {
+                var userGridError = JsonConvert.DeserializeObject<UsergridError>(response.Content);
+                throw new UsergridException(userGridError);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk/IClient.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk/IClient.cs b/Usergrid.Sdk/IClient.cs
new file mode 100644
index 0000000..b2fa827
--- /dev/null
+++ b/Usergrid.Sdk/IClient.cs
@@ -0,0 +1,73 @@
+\ufeff// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Collections.Generic;
+using Usergrid.Sdk.Model;
+
+namespace Usergrid.Sdk
+{
+    public interface IClient
+    {
+        void Login(string loginId, string secret, AuthType authType);
+        T CreateEntity<T>(string collection, T entity);
+        void DeleteEntity(string collection, string name);
+        void UpdateEntity<T>(string collection, string identifier, T entity);
+        T GetEntity<T>(string collectionName, string identifer);
+        
+        T GetUser<T>(string identifer /*username or uuid or email*/) where T : UsergridUser;
+        void CreateUser<T>(T user) where T : UsergridUser;
+        void UpdateUser<T>(T user) where T : UsergridUser;
+        void DeleteUser(string identifer /*username or uuid or email*/);
+        void ChangePassword(string identifer /*username or uuid or email*/, string oldPassword, string newPassword);
+        void CreateGroup<T>(T group) where T : UsergridGroup;
+        void DeleteGroup(string path);
+        T GetGroup<T>(string identifer /*uuid or path*/) where T : UsergridGroup;
+        void UpdateGroup<T>(T group) where T : UsergridGroup;
+        void AddUserToGroup(string groupIdentifier, string userName);
+        void DeleteUserFromGroup(string groupIdentifier, string userIdentifier);
+        IList<T> GetAllUsersInGroup<T>(string groupName) where T : UsergridUser;
+        
+        UsergridCollection<T> GetEntities<T>(string collection, int limit = 10, string query = null);
+        UsergridCollection<T> GetNextEntities<T>(string collection, string query = null);
+        UsergridCollection<T> GetPreviousEntities<T>(string collection, string query = null);
+
+        void CreateConnection(Connection connection);
+        IList<UsergridEntity> GetConnections(Connection connection);
+        IList<TConnectee> GetConnections<TConnectee>(Connection connection);
+        void DeleteConnection(Connection connection);
+        
+        void PostActivity<T>(string userIdentifier, T activity) where T:UsergridActivity;
+        void PostActivityToGroup<T>(string groupIdentifier, T activity) where T:UsergridActivity;
+        void PostActivityToUsersFollowersInGroup<T>(string userIdentifier, string groupIdentifier, T activity) where T:UsergridActivity;
+        UsergridCollection<T> GetUserActivities<T>(string userIdentifier) where T:UsergridActivity;
+        UsergridCollection<T> GetGroupActivities<T>(string groupIdentifier) where T:UsergridActivity;
+        UsergridCollection<T> GetUserFeed<T>(string userIdentifier) where T : UsergridActivity;
+        UsergridCollection<T> GetGroupFeed<T>(string groupIdentifier) where T : UsergridActivity;
+
+
+        void CreateNotifierForApple(string notifierName, string environment, string p12CertificatePath);
+        void CreateNotifierForAndroid(string notifierName, string apiKey);
+        T GetNotifier<T>(string identifer/*uuid or notifier name*/) where T : UsergridNotifier;
+        void DeleteNotifier(string notifierName);
+        
+        
+        T GetDevice<T>(string identifer) where T : UsergridDevice;
+        void UpdateDevice<T>(T device) where T : UsergridDevice;
+        void CreateDevice<T>(T device) where T : UsergridDevice;
+        void DeleteDevice(string identifer);
+        void PublishNotification (IEnumerable<Notification> notifications, INotificationRecipients recipients, NotificationSchedulerSettings schedulerSettings = null );
+        void CancelNotification(string notificationIdentifier);
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-dotnet/blob/94c0483c/Usergrid.Sdk/IUsergridRequest.cs
----------------------------------------------------------------------
diff --git a/Usergrid.Sdk/IUsergridRequest.cs b/Usergrid.Sdk/IUsergridRequest.cs
new file mode 100644
index 0000000..66842b1
--- /dev/null
+++ b/Usergrid.Sdk/IUsergridRequest.cs
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Collections.Generic;
+using RestSharp;
+
+namespace Usergrid.Sdk
+{
+    public interface IUsergridRequest
+    {
+        IRestResponse<T> ExecuteJsonRequest<T>(string resource, Method method, object body = null) where T : new();
+        IRestResponse ExecuteJsonRequest(string resource, Method method, object body = null);
+        IRestResponse ExecuteMultipartFormDataRequest(string resource, Method method, IDictionary<string, object> formParameters, IDictionary<string, string> fileParameters);
+        string AccessToken { get; set; }
+    }
+}