public void TestCreate() { // Arrange this.capture = new Klarna.Rest.OrderManagement.Capture(this.connector, this.orderUrl, string.Empty); this.requestMock.Expect(x => x.CreateRequest(this.baseUrl.ToString().TrimEnd('/') + this.orderUrl + this.path)).Return(this.httpWebRequest); CaptureData captureData = new CaptureData() { Description = "the desc...", CapturedAmount = 111 }; WebHeaderCollection headers = new WebHeaderCollection(); headers["Location"] = this.location; IResponse response = new Response(HttpStatusCode.Created, headers, string.Empty); this.requestMock.Expect(x => x.Send(this.httpWebRequest, captureData.ConvertToJson())).Return(response); // Act this.capture.Create(captureData); // Assert this.requestMock.VerifyAllExpectations(); Assert.AreEqual(this.location, this.capture.Location.OriginalString); Assert.AreEqual(captureData.ConvertToJson().Length, this.httpWebRequest.ContentLength); TestsHelper.AssertRequest(this.merchantId, this.secret, this.httpWebRequest, HttpMethod.Post); }
public void SetUp() { this.httpWebRequest = (HttpWebRequest)WebRequest.Create(this.baseUrl); this.requestMock = MockRepository.GenerateStub <IRequestFactory>(); this.connector = ConnectorFactory.Create(this.requestMock, this.merchantId, this.secret, this.userAgent, this.baseUrl); this.capture = new Klarna.Rest.OrderManagement.Capture(this.connector, this.orderUrl, "1002"); }
public void Capture_Constructor_NoCaptureId() { // Arrange // Act this.capture = new Klarna.Rest.OrderManagement.Capture(this.connectorMock, this.orderUrl, string.Empty); // Assert Assert.AreEqual(this.orderUrl + this.path, this.capture.Location.OriginalString); }
public void Capture_Constructor_CaptureId() { // Arrange string captureId = "captureId"; // Act this.capture = new Klarna.Rest.OrderManagement.Capture(this.connectorMock, this.orderUrl, captureId); // Assert Assert.AreEqual(this.orderUrl + this.path + "/" + captureId, this.capture.Location.ToString()); }
public void Capture_Path_Basic() { // Arrange Uri newTestLocation = new Uri("https://newTestLocation.test"); // Act this.capture = new Klarna.Rest.OrderManagement.Capture(this.connectorMock, newTestLocation, string.Empty); // Assert Assert.AreEqual(this.path, this.capture.Path); }
public void SetUp() { this.connectorMock = MockRepository.GenerateStub <IConnector>(); this.capture = new Klarna.Rest.OrderManagement.Capture(this.connectorMock, this.orderUrl, string.Empty); }