public void GetHarByUrl( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] SearchComponent sut, string regex, string baseUrl, int start, int count, Har har) { // ARRANGE httpClientMock.SetupApiCall(sut, CallType.Other, "harByUrlRegex", new Parameters { { "regex", regex }, { "baseurl", baseUrl }, { "start", start }, { "count", count } }, DataType.Other) .Returns(Har.Serialize(har)) .Verifiable(); // ACT var result = sut.GetHarByUrl(regex, baseUrl, start, count); // ASSERT result.ShouldBeEquivalentTo(har); httpClientMock.Verify(); }
public void GetMessagesHar( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] CoreComponent sut, string baseUrl, int start, int count, Har messages) { // ARRANGE httpClientMock.SetupApiCall(sut, CallType.Other, "messagesHar", new Parameters { { "baseurl", baseUrl }, { "start", start }, { "count", count } }, DataType.Other) .Returns(Har.Serialize(messages)) .Verifiable(); // ACT var result = sut.GetMessagesHar(baseUrl, start, count); // ASSERT result.ShouldBeEquivalentTo(messages); httpClientMock.Verify(); }
/// <summary> /// Sends an HTTP request defined in the <see cref="Har"/> format through the ZAP proxy and returns the obtained result messages. /// </summary> /// <param name="har">The HTTP request defined in the <see cref="Har"/> format.</param> /// <param name="followRedirects">Optional choice whether ZAP should follow redirects. Default is false.</param> /// <returns>Obtained result messages in <see cref="Har"/> format.</returns> public Har SendHarRequest(Har har, bool?followRedirects = false) { var result = CallOther("sendHarRequest", new Parameters { { "request", Har.Serialize(har) }, { "followRedirects", followRedirects } }); return(Har.Deserialize(result)); }
public void SerializeRoundtrip() { // ARRANGE var expected = Har.Deserialize(TestData.Sample); // ACT var actual = Har.Deserialize(Har.Serialize(expected)); // ASSERT actual.ShouldBeEquivalentTo(expected); }
public void EntryPageRefNotFound() { // ARRANGE var har = new Har(); har.Log.Entries.Add(new Entry { PageRef = "page_0" }); // ACT Action act = () => Har.Serialize(har); // ASSERT act.ShouldThrow <InvalidOperationException>().WithMessage(Resources.EntryPageRefNotFound); }
public void PageIdsNotUnique() { // ARRANGE var har = new Har(); har.Log.Pages.Add(new Page { Id = "page_0" }); har.Log.Pages.Add(new Page { Id = "page_0" }); // ACT Action act = () => Har.Serialize(har); // ASSERT act.ShouldThrow <InvalidOperationException>().WithMessage(Resources.PageIdsNotUnique); }
public void GetMessageHar( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] CoreComponent sut, int id, Har message) { // ARRANGE httpClientMock.SetupApiCall(sut, CallType.Other, "messageHar", new Parameters { { "id", id } }, DataType.Other) .Returns(Har.Serialize(message)) .Verifiable(); // ACT var result = sut.GetMessageHar(id); // ASSERT result.ShouldBeEquivalentTo(message); httpClientMock.Verify(); }
public void SendHarRequest( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] CoreComponent sut, Har request, bool followRedirects, Har response) { // ARRANGE httpClientMock.SetupApiCall(sut, CallType.Other, "sendHarRequest", new Parameters { { "request", Har.Serialize(request) }, { "followRedirects", followRedirects } }, DataType.Other) .Returns(Har.Serialize(response)) .Verifiable(); // ACT var result = sut.SendHarRequest(request, followRedirects); // ASSERT result.ShouldBeEquivalentTo(response); httpClientMock.Verify(); }