From 150a790ce9876857ee0e6027d8f2a9335ba5bab5 Mon Sep 17 00:00:00 2001 From: BurnSoft Date: Tue, 26 Apr 2022 16:51:52 -0400 Subject: [PATCH] #58 Added tests for more details to add to the add firearms test --- .../UI/Collection/AddWindow.cs | 380 +++++++++++++----- .../UI/Collection/AddTest.cs | 40 +- 2 files changed, 314 insertions(+), 106 deletions(-) diff --git a/BSMyGunCollection.UnitTest.Command.Helpers/UI/Collection/AddWindow.cs b/BSMyGunCollection.UnitTest.Command.Helpers/UI/Collection/AddWindow.cs index c1d3079..17a06f9 100644 --- a/BSMyGunCollection.UnitTest.Command.Helpers/UI/Collection/AddWindow.cs +++ b/BSMyGunCollection.UnitTest.Command.Helpers/UI/Collection/AddWindow.cs @@ -19,12 +19,30 @@ public static List RunTest(string manufacture,string importer, cmd.AddRange(Base.Sleep500()); cmd.AddRange(AddSimple(manufacture, importer, model, serialNumber, pistolType, caliber, condition, purchasedFrom, purchasedPrice, verify)); - cmd.AddRange(ClickOn.CancelButton(verify)); + cmd.AddRange(Details.ClickOn.CancelButton(verify)); cmd.AddRange(MainWindow.ToolBar.ClickOnAddGun()); cmd.AddRange(Base.Sleep500()); cmd.AddRange(AddSimple(manufacture, importer, model, serialNumber, pistolType, caliber, condition, purchasedFrom, purchasedPrice, verify)); - cmd.AddRange(ClickOn.AddButton(verify)); + cmd.AddRange(Details.ClickOn.AddButton(verify)); + cmd.AddRange(Base.Sleep()); + return cmd; + } + public static List RunTest(string manufacture, string importer, string model, + string serialNumber, string pistolType, string caliber, string condition, + string purchasedFrom, string purchasedPrice, string caliber2, string caliber3, string stockType, + string manufacturedDate, string action, string weight, string placeOfOrgin, string finish, + string storage, string sights, string feedSystem, string overallLength, string barrelLength, bool verify = false, string currentChoke = "") + { + List cmd = new List(); + cmd.AddRange(MainWindow.ToolBar.ClickOnAddGun()); + cmd.AddRange(Base.Sleep500()); + cmd.AddRange(AddSimple(manufacture, importer, model, serialNumber, pistolType, caliber, + condition, purchasedFrom, purchasedPrice, verify)); + cmd.AddRange(AddOtherDetails(caliber2, caliber3, stockType, manufacturedDate, action, + weight, placeOfOrgin, finish, storage, sights, feedSystem, overallLength, barrelLength, verify, currentChoke)); + + cmd.AddRange(Details.ClickOn.AddButton(verify)); cmd.AddRange(Base.Sleep()); return cmd; } @@ -47,133 +65,295 @@ internal static List AddSimple(string manufacture, string impo string purchasedFrom, string purchasedPrice, bool verify = false) { List cmd = new List(); - cmd.AddRange(ClickOn.Manufacture(verify)); - cmd.AddRange(FillIn.Manufacture(manufacture, verify)); - cmd.AddRange(ClickOn.Importer(verify)); - cmd.AddRange(FillIn.Importer(importer, verify)); - cmd.AddRange(ClickOn.Model(verify)); - cmd.AddRange(FillIn.Model(model, verify)); - cmd.AddRange(ClickOn.SerialNumber(verify)); - cmd.AddRange(FillIn.SerialNumber(serialNumber, verify)); - cmd.AddRange(ClickOn.PistolType(verify)); - cmd.AddRange(FillIn.PistolType(pistolType, verify)); - cmd.AddRange(ClickOn.Caliber(verify)); - cmd.AddRange(FillIn.Caliber(caliber, verify)); - cmd.AddRange(ClickOn.Condition(verify)); - cmd.AddRange(FillIn.Condition(condition, verify)); - cmd.AddRange(ClickOn.PurchasedFrom(verify)); - cmd.AddRange(FillIn.PurchasedFrom(purchasedFrom, verify)); - cmd.AddRange(ClickOn.PurchasedPrice(verify)); - cmd.AddRange(FillIn.PurchasedPrice(purchasedPrice, verify)); + cmd.AddRange(Details.ClickOn.Manufacture(verify)); + cmd.AddRange(Details.FillIn.Manufacture(manufacture, verify)); + cmd.AddRange(Details.ClickOn.Importer(verify)); + cmd.AddRange(Details.FillIn.Importer(importer, verify)); + cmd.AddRange(Details.ClickOn.Model(verify)); + cmd.AddRange(Details.FillIn.Model(model, verify)); + cmd.AddRange(Details.ClickOn.SerialNumber(verify)); + cmd.AddRange(Details.FillIn.SerialNumber(serialNumber, verify)); + cmd.AddRange(Details.ClickOn.PistolType(verify)); + cmd.AddRange(Details.FillIn.PistolType(pistolType, verify)); + cmd.AddRange(Details.ClickOn.Caliber(verify)); + cmd.AddRange(Details.FillIn.Caliber(caliber, verify)); + cmd.AddRange(Details.ClickOn.Condition(verify)); + cmd.AddRange(Details.FillIn.Condition(condition, verify)); + cmd.AddRange(Details.ClickOn.PurchasedFrom(verify)); + cmd.AddRange(Details.FillIn.PurchasedFrom(purchasedFrom, verify)); + cmd.AddRange(Details.ClickOn.PurchasedPrice(verify)); + cmd.AddRange(Details.FillIn.PurchasedPrice(purchasedPrice, verify)); return cmd; } - internal class ClickOn + internal static List AddOtherDetails(string caliber2, string caliber3, string stockType, string manufacturedDate, string action, + string weight, string placeOfOrgin, string finish, string storage, string sights, string feedSystem, + string overallLength, string barrelLength, bool verify = false, string currentChoke = "") { - internal static List Manufacture(bool verify = false) + List cmd = new List(); + cmd.AddRange(Details.ClickOn.Caliber2(verify)); + cmd.AddRange(Details.FillIn.Caliber2(caliber2, verify)); + cmd.AddRange(Details.ClickOn.Caliber3(verify)); + cmd.AddRange(Details.FillIn.Caliber3(caliber3, verify)); + cmd.AddRange(Details.ClickOn.StockGripType(verify)); + cmd.AddRange(Details.FillIn.StockGripType(stockType, verify)); + cmd.AddRange(Details.ClickOn.ManufacturedDate(verify)); + cmd.AddRange(Details.FillIn.ManufacturedDate(manufacturedDate, verify)); + cmd.AddRange(Details.ClickOn.Action(verify)); + cmd.AddRange(Details.FillIn.Action(action, verify)); + cmd.AddRange(Details.ClickOn.Weight(verify)); + cmd.AddRange(Details.FillIn.Weight(weight, verify)); + cmd.AddRange(Details.ClickOn.PlaceOfOrgin(verify)); + cmd.AddRange(Details.FillIn.PlaceOfOrgin(placeOfOrgin, verify)); + cmd.AddRange(Details.ClickOn.Finish(verify)); + cmd.AddRange(Details.FillIn.Finish(finish, verify)); + cmd.AddRange(Details.ClickOn.Storage(verify)); + cmd.AddRange(Details.FillIn.Storage(storage, verify)); + cmd.AddRange(Details.ClickOn.Sights(verify)); + cmd.AddRange(Details.FillIn.Sights(sights, verify)); + cmd.AddRange(Details.ClickOn.FeedSystem(verify)); + cmd.AddRange(Details.FillIn.FeedSystem(feedSystem, verify)); + cmd.AddRange(Details.ClickOn.OverallLength(verify)); + cmd.AddRange(Details.FillIn.OverallLength(overallLength, verify)); + cmd.AddRange(Details.ClickOn.BarrelLength(verify)); + cmd.AddRange(Details.FillIn.BarrelLength(barrelLength, verify)); + if (currentChoke.Length > 0) { - return Base.ClickOnElement("Manufacture", "txtManu", verify); + cmd.AddRange(Details.ClickOn.CurrentChoke(verify)); + cmd.AddRange(Details.FillIn.CurrentChoke(currentChoke, verify)); } + + return cmd; + } - internal static List Importer(bool verify = false) + internal class Details + { + internal class ClickOn { - return Base.ClickOnElement("Importer", "txtImporter", verify); - } + internal static List OverallLength(bool verify = false) + { + return Base.ClickOnElement("Overal lLength", "txtLength", verify); + } + internal static List BarrelLength(bool verify = false) + { + return Base.ClickOnElement("BarrelLength", "txtBarLen", verify); + } + internal static List CurrentChoke(bool verify = false) + { + return Base.ClickOnElement("Current Choke", "txtChoke", verify); + } - internal static List Model(bool verify = false) - { - return Base.ClickOnElement("Model", "txtModel", verify); - } + internal static List Weight(bool verify = false) + { + return Base.ClickOnElement("Weight", "txtWeight", verify); + } + internal static List PlaceOfOrgin(bool verify = false) + { + return Base.ClickOnElement("Place of origin", "txtNationality", verify); + } + internal static List Finish(bool verify = false) + { + return Base.ClickOnElement("Finish", "txtFinish", verify); + } + internal static List Storage(bool verify = false) + { + return Base.ClickOnElement("Storage Location", "txtStorage", verify); + } + internal static List Sights(bool verify = false) + { + return Base.ClickOnElement("Sigths", "txtSights", verify); + } + internal static List FeedSystem(bool verify = false) + { + return Base.ClickOnElement("Feed System", "txtFeed", verify); + } - internal static List SerialNumber( bool verify = false) - { - return Base.ClickOnElement("Serial Number", "txtSerial", verify); - } + internal static List Manufacture(bool verify = false) + { + return Base.ClickOnElement("Manufacture", "txtManu", verify); + } - internal static List PistolType(bool verify = false) - { - return Base.ClickOnElement("Type", "txtType", verify); - } + internal static List Importer(bool verify = false) + { + return Base.ClickOnElement("Importer", "txtImporter", verify); + } - internal static List Caliber( bool verify = false) - { - return Base.ClickOnElement("Caliber", "txtCal", verify); - } + internal static List Model(bool verify = false) + { + return Base.ClickOnElement("Model", "txtModel", verify); + } - internal static List Condition(bool verify = false) - { - return Base.ClickOnElement("Condition", "cmdCondition", verify); - } + internal static List SerialNumber(bool verify = false) + { + return Base.ClickOnElement("Serial Number", "txtSerial", verify); + } - internal static List PurchasedFrom(bool verify = false) - { - return Base.ClickOnElement("Purchased From", "txtPurchasedFrom", verify); - } + internal static List PistolType(bool verify = false) + { + return Base.ClickOnElement("Type", "txtType", verify); + } - internal static List PurchasedPrice(bool verify = false) - { - return Base.ClickOnElement("Purchased Price", "txtPurPrice", verify); - } + internal static List Caliber(bool verify = false) + { + return Base.ClickOnElement("Caliber", "txtCal", verify); + } - internal static List AddButton(bool verify = false) - { - return Base.ClickOnElement("Add button", "btnAdd", verify); - } + internal static List Condition(bool verify = false) + { + return Base.ClickOnElement("Condition", "cmdCondition", verify); + } - internal static List CancelButton(bool verify = false) - { - return Base.ClickOnElement("Cancel button", "btnCancel", verify); - } + internal static List PurchasedFrom(bool verify = false) + { + return Base.ClickOnElement("Purchased From", "txtPurchasedFrom", verify); + } - } - internal class FillIn - { - internal static List Manufacture(string value, bool verify = false) - { - return Base.SendTExt("Manufacture", "txtManu", value,verify); - } + internal static List PurchasedPrice(bool verify = false) + { + return Base.ClickOnElement("Purchased Price", "txtPurPrice", verify); + } - internal static List Importer(string value, bool verify = false) - { - return Base.SendTExt("Importer", "txtImporter", value, verify); - } + internal static List AddButton(bool verify = false) + { + return Base.ClickOnElement("Add button", "btnAdd", verify); + } - internal static List Model(string value, bool verify = false) - { - return Base.SendTExt("Model", "txtModel", value, verify); - } + internal static List CancelButton(bool verify = false) + { + return Base.ClickOnElement("Cancel button", "btnCancel", verify); + } - internal static List SerialNumber(string value, bool verify = false) - { - return Base.SendTExt("Serial Number", "txtSerial", value, verify); - } + internal static List Caliber2(bool verify = false) + { + return Base.ClickOnElement("Caliber 2", "txtPetLoads", verify); + } - internal static List PistolType(string value, bool verify = false) - { - return Base.SendTExt("Type", "txtType", value, verify); - } + internal static List Caliber3(bool verify = false) + { + return Base.ClickOnElement("Caliber 3", "txtCaliber3", verify); + } - internal static List Caliber(string value, bool verify = false) - { - return Base.SendTExt("Caliber", "txtCal", value, verify); - } + internal static List StockGripType(bool verify = false) + { + return Base.ClickOnElement("Stock Grip Type", "txtGripType", verify); + } - internal static List Condition(string value, bool verify = false) - { - return Base.SendTExt("Condition", "cmdCondition", value, verify); - } + internal static List ManufacturedDate(bool verify = false) + { + return Base.ClickOnElement("Manufactured Date", "txtProduced", verify); + } + internal static List Action(bool verify = false) + { + return Base.ClickOnElement("Action", "txtAction", verify); + } - internal static List PurchasedFrom(string value, bool verify = false) - { - return Base.SendTExt("Purchased From", "txtPurchasedFrom", value, verify); } - - internal static List PurchasedPrice(string value, bool verify = false) + internal class FillIn { - return Base.SendTExt("Purchased Price", "txtPurPrice", value, verify); - } + internal static List OverallLength(string value, bool verify = false) + { + return Base.SendTExt("Overal lLength", "txtLength", value, verify); + } + internal static List BarrelLength(string value, bool verify = false) + { + return Base.SendTExt("BarrelLength", "txtBarLen", value, verify); + } + internal static List CurrentChoke(string value, bool verify = false) + { + return Base.SendTExt("Current Choke", "txtChoke", value, verify); + } + internal static List Weight(string value, bool verify = false) + { + return Base.SendTExt("Weight", "txtWeight", value, verify); + } + internal static List PlaceOfOrgin(string value, bool verify = false) + { + return Base.SendTExt("Place of origin", "txtNationality", value, verify); + } + internal static List Finish(string value, bool verify = false) + { + return Base.SendTExt("Finish", "txtFinish", value, verify); + } + internal static List Storage(string value, bool verify = false) + { + return Base.SendTExt("Storage Location", "txtStorage", value, verify); + } + internal static List Sights(string value, bool verify = false) + { + return Base.SendTExt("Sigths", "txtSights", value, verify); + } + internal static List FeedSystem(string value, bool verify = false) + { + return Base.SendTExt("Feed System", "txtFeed", value, verify); + } + internal static List StockGripType(string value, bool verify = false) + { + return Base.SendTExt("Stock Grip Type", "txtGripType", value, verify); + } + internal static List ManufacturedDate(string value, bool verify = false) + { + return Base.SendTExt("Manufactured Date", "txtProduced", value, verify); + } + internal static List Action(string value, bool verify = false) + { + return Base.SendTExt("Action", "txtAction", value, verify); + } + internal static List Caliber2(string value, bool verify = false) + { + return Base.SendTExt("Caliber 2", "txtPetLoads", value, verify); + } + internal static List Caliber3(string value, bool verify = false) + { + return Base.SendTExt("Caliber 3", "txtCaliber3", value, verify); + } + internal static List Manufacture(string value, bool verify = false) + { + return Base.SendTExt("Manufacture", "txtManu", value, verify); + } + + internal static List Importer(string value, bool verify = false) + { + return Base.SendTExt("Importer", "txtImporter", value, verify); + } + + internal static List Model(string value, bool verify = false) + { + return Base.SendTExt("Model", "txtModel", value, verify); + } + internal static List SerialNumber(string value, bool verify = false) + { + return Base.SendTExt("Serial Number", "txtSerial", value, verify); + } + + internal static List PistolType(string value, bool verify = false) + { + return Base.SendTExt("Type", "txtType", value, verify); + } + + internal static List Caliber(string value, bool verify = false) + { + return Base.SendTExt("Caliber", "txtCal", value, verify); + } + + internal static List Condition(string value, bool verify = false) + { + return Base.SendTExt("Condition", "cmdCondition", value, verify); + } + + internal static List PurchasedFrom(string value, bool verify = false) + { + return Base.SendTExt("Purchased From", "txtPurchasedFrom", value, verify); + } + + internal static List PurchasedPrice(string value, bool verify = false) + { + return Base.SendTExt("Purchased Price", "txtPurPrice", value, verify); + } + + } } + } } diff --git a/BSMyGunCollection.UnitTest/UI/Collection/AddTest.cs b/BSMyGunCollection.UnitTest/UI/Collection/AddTest.cs index 1bdf30d..e4550a0 100644 --- a/BSMyGunCollection.UnitTest/UI/Collection/AddTest.cs +++ b/BSMyGunCollection.UnitTest/UI/Collection/AddTest.cs @@ -53,11 +53,11 @@ public class AddTest /// /// The add firearm manufacture /// - private string AddFirearmManufacture; + private string _addFirearmManufacture; /// /// The add firearm model /// - private string AddFirearmModel; + private string _addFirearmModel; /// /// Initializes this instance. /// @@ -71,8 +71,8 @@ public void Init() _appName = Vs2019.GetSetting("AppName"); _errLog = Vs2019.GetSetting("ErrorLogName"); _firearmToView = Vs2019.GetSetting("FirearmToView"); - AddFirearmManufacture = Vs2019.GetSetting("AddFirearmManufacture"); - AddFirearmModel = Vs2019.GetSetting("AddFirearmModel"); + _addFirearmManufacture = Vs2019.GetSetting("AddFirearmManufacture"); + _addFirearmModel = Vs2019.GetSetting("AddFirearmModel"); _fullAppPath = Path.Combine(_appPath, _appName); _fullLogPath = Path.Combine(_appPath, _errLog); @@ -134,7 +134,7 @@ private void DumpResults(List value) private void VerifyDoesntExist() { string dbPath = BurnSoft.Applications.MGC.ThirdParty.Main.GetDatabaseLocation(out _); - string fullname = $"{AddFirearmManufacture} {AddFirearmModel}"; + string fullname = $"{_addFirearmManufacture} {_addFirearmModel}"; if (BurnSoft.Applications.MGC.Firearms.MyCollection.Exists(dbPath, fullname, out _)) { @@ -149,7 +149,7 @@ public void AddSimpleTest() try { List value = _ga.RunBatchCommands(Command.Helpers.UI.Collection.AddWindow.RunTest( - AddFirearmManufacture, "GitHub", AddFirearmModel, + _addFirearmManufacture, "GitHub", _addFirearmModel, "UTF0293845", "Pistol: Semi-Auto - SA Only", "9mm Luger", "90%","WebGunShop","499.99"), out _errOut); if (_errOut.Length > 0) throw new Exception(_errOut); @@ -168,5 +168,33 @@ public void AddSimpleTest() } Assert.IsTrue(bans); } + + [TestMethod] + public void AddJustABoutEverythingTest() + { + bool bans = false; + try + { + List value = _ga.RunBatchCommands(Command.Helpers.UI.Collection.AddWindow.RunTest( + _addFirearmManufacture, "GitHub", _addFirearmModel, + "UTF0293845", "Pistol: Semi-Auto - SA Only", "9mm Luger", + "90%", "WebGunShop", "499.99", "9mm kurtz","","plastic","1/1/1990","blow back","16oz", + "USA","black","Gun Locker","fixed irons","30 round magazine","5 in.","4.5 in." ), out _errOut); + if (_errOut.Length > 0) throw new Exception(_errOut); + DumpResults(value); + bans = _ga.AllTestsPassed(value); + + if (ErrLogExists()) + { + bans = false; + throw new Exception($"ERROR LOG EXISTS!! {_fullLogPath}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + } + Assert.IsTrue(bans); + } } }