public void ShouldReturnUserInfoAfterInsert() { var apiClient = new HttpClient(_server); var userId = Guid.NewGuid(); var reqDate = DateTime.Now; var rightPostData = new SyncProfileRequest { UserId = userId, RequestId = Guid.NewGuid(), AdvertisingOptIn = true, CountryIsoCode = "US", Locale = "en-US", DateModified = reqDate, }; using (var request = RequestBuilder.CreateRequest(_url, "import.json", "application/json", HttpMethod.Post, rightPostData, new JsonMediaTypeFormatter())) using (HttpResponseMessage response = apiClient.SendAsync(request).Result) { Assert.That(response.StatusCode == HttpStatusCode.OK); } using (var proxy = new UserInfoProviderProxy(new ServiceEndpoint(ContractDescription.GetContract(typeof(IUserInfoProvider)), new BasicHttpBinding(), new EndpointAddress(Program.WcfBaseAddress)))) { var userInfo = proxy.GetUserInfo(userId); Assert.That(userInfo != null); Assert.That(userInfo.UserId == userId); Assert.That(DatesAreEqual(userInfo.DateModified, reqDate)); } }
public void ShouldThrowOnNotFound() { using (var proxy = new UserInfoProviderProxy(new ServiceEndpoint(ContractDescription.GetContract(typeof(IUserInfoProvider)), new BasicHttpBinding(), new EndpointAddress(Program.WcfBaseAddress)))) { Assert.Throws <FaultException <UserNotFound> >(() => proxy.GetUserInfo(Guid.NewGuid())); } }