Skip to content

Conversation

@nadvolod
Copy link
Contributor

@nadvolod nadvolod commented Dec 30, 2019

I've updated the C# implementation to match what we have been doing in Java. This is a pretty good preview of where the bindings can go. Please let me know your thoughts.

@nadvolod nadvolod added the dotnet .NET Bindings label Dec 30, 2019
Copy link
Contributor

@titusfortner titusfortner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't spend a lot of time looking at this versus master, and I just knocked out a few ideas for how to split up these classes in the last two commits on this branch: https://github.com/saucelabs/simple_sauce/commits/dotnet_titus

I only got so far on that code before I stopped. Let me know if you want me to do more with it.

private readonly Dictionary<string, object> _sauceConfiguration;

public SauceOptions()
public SauceOptions() : this(new DriverFactory())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest issue is that Options shouldn't know anything about the Driver.

}

public SauceSession(SauceOptions options, ISauceRemoteDriver driver)
public SauceSession(SauceOptions options, IWebDriver driver)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session is responsible for creating a driver session, not be initialized with a driver instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The Java case of SauceOptions doesn't allow any form of WebDriver to be passed in to constructors or getters. This should be the same in the .NET case.

public EdgeOptions ConfiguredEdgeOptions { get; set; }
public ChromeOptions ConfiguredChromeOptions { get; private set; }
public SafariOptions ConfiguredSafariOptions { get; set; }
public DataCenter DataCenter { get; set; } = DataCenter.UsWest;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data Center is a Session concern not an Options concern

}

public IDriverFactory DriverFactory { get; }
public EdgeOptions ConfiguredEdgeOptions { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need to have separate configurations for each browser implementation. They are all type DriverOptions, we just need to be able to get the formatting to the Session when asked.

}

public SauceSession(SauceOptions options, ISauceRemoteDriver driver)
public SauceSession(SauceOptions options, IWebDriver driver)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The Java case of SauceOptions doesn't allow any form of WebDriver to be passed in to constructors or getters. This should be the same in the .NET case.

};
}

public IWebDriver CreateEdgeBrowser()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's the Firefox case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To expound on this, we shouldn't need anything that is specific to a browser here. For Typing we should be able to use the superclass.

@nadvolod
Copy link
Contributor Author

nadvolod commented Jan 6, 2020

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 4
           

Complexity increasing per file
==============================
- dotnet/SimpleSauce.Test/SauceOptionsTests.cs  1
- dotnet/SimpleSauce.Test/DriverFactoryTests.cs  1
- dotnet/Simple.Sauce/DriverFactory.cs  4
         

Complexity decreasing per file
==============================
+ dotnet/Simple.Sauce/SauceSession.cs  -1
         

Clones added
============
- dotnet/SimpleSauce.Test/SauceOptionsTests.cs  1
- dotnet/SimpleSauce.Test/DriverFactoryTests.cs  1
- dotnet/SimpleSauce.Test/SauceSessionTests.cs  1
         

Clones removed
==============
+ dotnet/SimpleSauce.Test/BaselineSeleniumAcceptanceTests.cs  -1
+ dotnet/SimpleSauce.Test/SimpleSauceAcceptanceTests.cs  -1
         

See the complete overview on Codacy

Options = new SauceOptions();
}
private IWebDriver _driver;
private IDriverFactory _driverFactory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver = new SauceDriver();
Options = new SauceOptions();
}
private IWebDriver _driver;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
private readonly string _sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME");
private readonly string _sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY");
public readonly Dictionary<string, object> _sauceConfiguration;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
private Mock<ISauceRemoteDriver> _dummyDriver;
private Mock<IDriverFactory> _driverFactory;
private Mock<SauceOptions> _mockOptions;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from master to main March 15, 2021 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants