How to use Equals method of Microsoft.Playwright.Core.StorageStateOrigin class

Best Playwright-dotnet code snippet using Microsoft.Playwright.Core.StorageStateOrigin.Equals

Run Playwright-dotnet automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

StorageStateOrigin.cs

Source: StorageStateOrigin.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.Linq;
28
29namespace Microsoft.Playwright.Core
30{
31    /// <summary>
32    /// See <see cref="StorageState.Origins"/>.
33    /// </summary>
34    internal class StorageStateOrigin : IEquatable<StorageStateOrigin>
35    {
36        /// <summary>
37        /// Origin.
38        /// </summary>
39        public string Origin { get; set; }
40
41        /// <summary>
42        /// Local storage.
43        /// </summary>
44        public ICollection<NameValueEntry> LocalStorage { get; set; } = new List<NameValueEntry>();
45
46        public bool Equals(StorageStateOrigin other)
47            => other != null &&
48                Origin == other.Origin &&
49                LocalStorage.SequenceEqual(other.LocalStorage);
50
51        public override int GetHashCode()
52            => 412870874 +
53                EqualityComparer<string>.Default.GetHashCode(Origin) +
54                EqualityComparer<ICollection<NameValueEntry>>.Default.GetHashCode(LocalStorage);
55
56        public override bool Equals(object obj) => Equals(obj as StorageStateOrigin);
57    }
58}
59
Full Screen

StorageState.cs

Source: StorageState.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.Linq;
28
29namespace Microsoft.Playwright.Core
30{
31    internal class StorageState : IEquatable<StorageState>
32    {
33        /// <summary>
34        /// Cookie list.
35        /// </summary>
36        public ICollection<Cookie> Cookies { get; set; } = new List<Cookie>();
37
38        /// <summary>
39        /// List of local storage per origin.
40        /// </summary>
41        public ICollection<StorageStateOrigin> Origins { get; set; } = new List<StorageStateOrigin>();
42
43        public bool Equals(StorageState other)
44            => other != null &&
45                Cookies.SequenceEqual(other.Cookies) &&
46                Origins.SequenceEqual(other.Origins);
47
48        public override int GetHashCode()
49            => 412870874 +
50                EqualityComparer<ICollection<Cookie>>.Default.GetHashCode(Cookies) +
51                EqualityComparer<ICollection<StorageStateOrigin>>.Default.GetHashCode(Origins);
52
53        public override bool Equals(object obj) => Equals(obj as StorageState);
54    }
55}
56
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in StorageStateOrigin

Trigger Equals code on LambdaTest Cloud Grid

Execute automation tests with Equals on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)