public async Task DbSetPostAsyncResourceAttributeNull() { //Arrange var mockRestClient = new Mock<IRestClient>(); var dbSet = new DbSet<MockDbsetContact>(mockRestClient.Object); //Act await dbSet.PostAsync(new MockDbsetContact()); //Assert - throws }
public async Task DbSetPostAsyncTest() { //Arrange var mockRestResponse = new Mock<IRestResponse>(); mockRestResponse.SetupGet(o => o.ResponseStatus).Returns(ResponseStatus.Completed); mockRestResponse.SetupGet(o => o.StatusCode).Returns(HttpStatusCode.OK); mockRestResponse.SetupGet(o => o.Content).Returns(@"{ ""contactId"": ""48620"", ""id"": ""10002"", ""fieldValues"": [ { ""id"": ""824"", ""value"": ""transxId12321321321321"" } ], ""name"": ""Bob Tester"", ""uri"": ""/data/customObject"" } "); var mockRestClient = new Mock<IRestClient>(); mockRestClient.Setup(o => o.ExecuteTaskAsync(It.IsAny<IRestRequest>())).ReturnsAsync(mockRestResponse.Object); var dbSet = new DbSet<MockDbsetWithDataContact>(mockRestClient.Object); var mockContact = new MockDbsetWithDataContact { Name = "Bob Tester", ContactId = 48620, CustomField = "Custuom Rims", Uri = "/contact/id" }; //Act var contact = await dbSet.PostAsync(mockContact); //Assert Assert.AreEqual(48620, contact.ContactId); }