public void PostProfile_ValidIdAndValidProfile_NoExceptionsThrown() { //Arrange const string ProfileId = "adaSfaqwfasfasdasdfasfasfasd"; ProfileToPost profile = new ProfileToPost { FirstName = "NewFirstName", LastName = "NewLastName" }; Mock<IHttpTransport> httpTransportMock = new Mock<IHttpTransport>(MockBehavior.Strict); httpTransportMock.Setup(httpTransport => httpTransport.Request(It.IsAny<string>(), It.IsAny<ContentType>(), "POST", It.IsAny<string>(), null)) .Returns(string.Empty); //Action NextCallerClient client = new NextCallerClient(httpTransportMock.Object); client.UpdateByProfileId(ProfileId, profile); //Assert httpTransportMock.Verify(httpTransport => httpTransport.Request(It.IsAny<string>(), It.IsAny<ContentType>(), "POST", It.IsAny<string>(), null), Times.Once); }
public static void Run() { const string Username = ""; const string Password = ""; const bool Sandbox = true; NextCallerClient client = new NextCallerClient(Username, Password, Sandbox); const string ProfileId = "profileId"; try { ProfileToPost profile = new ProfileToPost { Email = "*****@*****.**", FirstName = "Clark", LastName = "Kent", PrimaryAddress = new Address { Line1 = "223 Kryptonite Ave.", Line2 = "", City = "Smallville", State = "KS", ZipCode = "66002" }, SecondaryAddress = new Address { Line1 = "223 Kryptonite Ave.", Line2 = "", City = "Smallville", State = "KS", ZipCode = "66002" }, }; client.UpdateByProfileId(ProfileId, profile); } catch (FormatException formatException) { HttpWebRequest request = formatException.Request; HttpWebResponse response = formatException.Response; HttpStatusCode code = response.StatusCode; Console.WriteLine("Status code: {0}", code); string reasonPhrase = response.StatusDescription; Console.WriteLine("Reason Phrase: {0}", reasonPhrase); string responseContent = formatException.Content; Console.WriteLine("Content : {0}", responseContent); } catch (BadRequestException badRequestException) { HttpWebRequest request = badRequestException.Request; HttpWebResponse response = badRequestException.Response; Error parsedError = badRequestException.Error; string errorCode = parsedError.Code; string message = parsedError.Message; string type = parsedError.Type; Dictionary<string, string[]> description = parsedError.Description; Console.WriteLine(parsedError.ToString()); } }