Skip to content

Commit

Permalink
Merge pull request #65 from No3Mc/Syed
Browse files Browse the repository at this point in the history
Week 24 | Everything done just the issue with ↙
  • Loading branch information
No3Mc authored Mar 13, 2022
2 parents 5a02ae7 + 87eef8f commit 1a6533d
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 78 deletions.
40 changes: 10 additions & 30 deletions Phone Selling System/PSSClasses/Stock/clsStockCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,36 +161,16 @@ public void Update()
//return NThisStock.StockID;
}































public void ReportByLocation(string Location)
{
//filters the records based on a full or partial location
//connect to the database
clsDataConnection DB = new clsDataConnection();
//send the location parameter to the database
DB.AddParameter("@Location", Location);
//execute the stored procedure
DB.Execute("sproc_tblStock_FilterByLocation");
}
}


Expand Down
171 changes: 123 additions & 48 deletions Phone Selling System/PhoneSystemTesting/Stock/tstStockCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ public void StockListOK()
}


[TestMethod]
public void CountPropertyOK()
{
//create an instance of the class we want to create
clsStockCollection AllStocks = new clsStockCollection();
//create some test data to assign to the proeprty
Int32 SomeCount = 0;
//assign the data to the property
AllStocks.Count = SomeCount;
//test to see that the two values are the same
Assert.AreEqual(AllStocks.Count, SomeCount);
}
//[TestMethod]
//public void CountPropertyOK()
//{
// //create an instance of the class we want to create
// clsStockCollection AllStocks = new clsStockCollection();
// //create some test data to assign to the proeprty
// Int32 SomeCount = 0;
// //assign the data to the property
// AllStocks.Count = SomeCount;
// //test to see that the two values are the same
// Assert.AreEqual(AllStocks.Count, SomeCount);
//}
//For quick copy paste StockName, WarehouseNo, Location, Quantity, Barcode

[TestMethod]
public void ThisStockPropertyOK()
Expand Down Expand Up @@ -152,6 +153,35 @@ public void DelMethodOK()
}


[TestMethod]
public void ListAndCountOK()
{
//create an instance of the class we want to create
clsStockCollection AllStocks = new clsStockCollection();
//create some test data to assign for the property
//in this case the data need to be a list of objects
List<clsStock> TestList = new List<clsStock>();
//add an item to the list
//create the item of test data
clsStock TestItem = new clsStock();
//set its properties
TestItem.StockID = 1;
TestItem.StockName = "1";
TestItem.WarehouseNo = "1";
TestItem.Location = "1";
TestItem.Quantity = "1";
TestItem.Barcode = "1";

//add the item to the property
TestList.Add(TestItem);
//assign the data to the property
AllStocks.StockList = TestList;
//test to see that two values are the same
Assert.AreEqual(AllStocks.Count, TestList.Count);
}
//For quick copy paste StockName, WarehouseNo, Location, Quantity, Barcode


[TestMethod]
public void UpdateMethodOK()
{
Expand Down Expand Up @@ -183,52 +213,95 @@ public void UpdateMethodOK()
Assert.AreEqual(AllStocks.ThisStock, TestItem);
}

//For quick copy paste StockName, WarehouseNo, Location, Quantity, Barcode


[TestMethod]
public void ReportByLocationMethodOK()
{
//create an instance of the class containing unfiltered results
clsStockCollection AllStocks = new clsStockCollection();
//create an instance of the filtered data
clsStockCollection FilteredStocks = new clsStockCollection();
//apply a blank string (should return all records)
FilteredStocks.ReportByLocation("2222");
//test to see ThisBook mathces the test data
Assert.AreEqual(AllStocks.Count, FilteredStocks.Count);
}

//[TestMethod]
//public void ReportByLocationTestDataFound()
//{

// //create an instance of the filtered data
// clsStockCollection FilteredStocks = new clsStockCollection();
// //var to store outcome
// bool OK = true;
// //apply a post code that doesn't exist
// FilteredStocks.ReportByLocation("aaaaa");
// //check that the correct number of record are found
// if (FilteredStocks.Count == 2)
// {
// //check that the first record is ID 21
// if (FilteredStocks.StockList[0].StockID != 21)
// {
// OK = false;

// }
// //check that the first record is ID 26
// if (FilteredStocks.StockList[1].StockID != 26)
// {
// OK = false;
// }

// }
// else
// {
// OK = false;
// }
// //test to see that there are no records
// Assert.IsTrue(OK);
//}

//got rid of these two tests according to the lab 23

//[TestMethod]
//public void ListAndCountOK()
//{
// //create an instance of the class we want to create
// clsStockCollection AllStocks = new clsStockCollection();
// //create some test data to assign to the property
// //in this case the data needs to be a list of objects
// List<clsStock> TestList = new List<clsStock>();
// //add an item to the list
// //create the item of test data
// clsStock TestItem = new clsStock();
// //set its properties
// TestItem.StockID = 1;
// TestItem.StockName = "1";
// TestItem.Location = "1";
// TestItem.Quantity = "1";
// TestItem.WarehouseNo = "1";
// TestItem.Barcode = "1";
// //add the item to the test list
// TestList.Add(TestItem);
// //assign the data of the property
// AllStocks.StockList = TestList;
// //test to see that the two values are the same
// Assert.AreEqual(AllStocks.Count, TestList.Count);

//}
//got rid of these two tests according to the lab 23

//[TestMethod]
//public void ListAndCountOK()
//{
// //create an instance of the class we want to create
// clsStockCollection AllStocks = new clsStockCollection();
// //create some test data to assign to the property
// //in this case the data needs to be a list of objects
// List<clsStock> TestList = new List<clsStock>();
// //add an item to the list
// //create the item of test data
// clsStock TestItem = new clsStock();
// //set its properties
// TestItem.StockID = 1;
// TestItem.StockName = "1";
// TestItem.Location = "1";
// TestItem.Quantity = "1";
// TestItem.WarehouseNo = "1";
// TestItem.Barcode = "1";
// //add the item to the test list
// TestList.Add(TestItem);
// //assign the data of the property
// AllStocks.StockList = TestList;
// //test to see that the two values are the same
// Assert.AreEqual(AllStocks.Count, TestList.Count);

//[TestMethod]
//public void TwoRecordsPresent()
//{
// //create an instance of the class we want to create
// clsStockCollection AllStocks = new clsStockCollection();
// //test to see that the two values are the same
// Assert.AreEqual(AllStocks.Count, 2);
//}
//}


//[TestMethod]
//public void TwoRecordsPresent()
//{
// //create an instance of the class we want to create
// clsStockCollection AllStocks = new clsStockCollection();
// //test to see that the two values are the same
// Assert.AreEqual(AllStocks.Count, 2);
//}



Expand All @@ -239,7 +312,9 @@ public void UpdateMethodOK()



}


}


}

0 comments on commit 1a6533d

Please sign in to comment.