コード例 #1
0
        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);
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void SetUp()
 {
     this.connectorMock = MockRepository.GenerateStub <IConnector>();
     this.capture       = new Klarna.Rest.OrderManagement.Capture(this.connectorMock, this.orderUrl, string.Empty);
 }