예제 #1
0
        public void ShouldSubmitFormWithCorrectControlData()
        {
            var dummyFormStrategy = MockRepository.GenerateStub<IForm>();
            dummyFormStrategy.Expect(f => f.GetFormInfo(PreviousResponse)).Return(DummyFormInfo);
            dummyFormStrategy.Expect(f => f.GetFormDataStrategy(PreviousResponse)).Return(DummyFormDataStrategy);

            var mockEndpoint = new MockEndpoint(new HttpResponseMessage());
            var client = new HttpClient {Channel = mockEndpoint};

            var submitForm = new SubmitForm(dummyFormStrategy);
            submitForm.Execute(PreviousResponse, StateVariables, new ClientCapabilities(client));

            Assert.AreEqual(ResourceUri, mockEndpoint.ReceivedRequest.RequestUri);
            Assert.AreEqual(HttpMethod, mockEndpoint.ReceivedRequest.Method);
            Assert.AreEqual(ExampleMediaType.ContentType, mockEndpoint.ReceivedRequest.Content.Headers.ContentType);
        }
예제 #2
0
        public void ShouldUseFormDataStrategyToCreateFormData()
        {
            var dummyEndpoint = new MockEndpoint(new HttpResponseMessage());
            var client = new HttpClient {Channel = dummyEndpoint};
            var clientCapabilities = new ClientCapabilities(client);

            var mockFormDataStrategy = MockRepository.GenerateMock<IFormDataStrategy>();
            mockFormDataStrategy.Expect(s => s.CreateFormData(PreviousResponse, StateVariables, clientCapabilities)).Return(new StringContent(string.Empty));

            var dummyFormStrategy = MockRepository.GenerateStub<IForm>();
            dummyFormStrategy.Expect(f => f.GetFormInfo(PreviousResponse)).Return(DummyFormInfo);
            dummyFormStrategy.Expect(f => f.GetFormDataStrategy(PreviousResponse)).Return(mockFormDataStrategy);

            var submitForm = new SubmitForm(dummyFormStrategy);
            submitForm.Execute(PreviousResponse, StateVariables, clientCapabilities);

            mockFormDataStrategy.VerifyAllExpectations();
        }